← Documents Documentation/arch/arm64/sme.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

Scalable Matrix Extension Support for AArch64 Linux

SME의 per-thread state, Streaming vector length, signal ABI, prctl/ptrace, coredump와 runtime default를 설명합니다.

Source pathDocumentation/arch/arm64/sme.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

sme.rst:1-461

SME는 normal SVE와 독립적인 Streaming vector length, `ZA` matrix, SME2의 `ZT0`를 추가합니다. Linux ABI의 핵심은 mode 전환 때 live register 범위를 명확히 하고 signal·ptrace·exec 경계에서 VL과 matrix state를 일관되게 보존하거나 무효화하는 것입니다.

SME state 경계
Thread SME stateSyscall: ZA 보존, SM clearSignal: SM/ZA/TPIDR2 clearFrame에 ZA/ZT/TPIDR2 저장sigreturn에서 검증 후 복원
`PR_SME_SET_VL`지원 VL로 roundRegister 일부 unspecified`PSTATE.ZA` clear

Thread state가 syscall, signal, exec 경계를 통과할 때 적용되는 핵심 전환입니다.

SME register surface
State크기/조건Linux ABI
`PSTATE.SM`Streaming mode 1 bitSignal entry에서 0
`PSTATE.ZA`ZA enable 1 bit`za_context`, `NT_ARM_ZA`
`ZA``SVL x SVL` bitsHorizontal vector encoding
`ZT0`SME2, 512 bits`zt_context`, `NT_ARM_ZT`
`TPIDR2_EL0`Per-thread`tpidr2_context`, `NT_ARM_TLS`

Architecture state와 Linux 관찰 경로를 연결합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ===================================================
2 Scalable Matrix Extension support for AArch64 Linux
3 ===================================================
4
5 This document outlines briefly the interface provided to userspace by Linux in
6 order to support use of the ARM Scalable Matrix Extension (SME).
7
8 This is an outline of the most important features and issues only and not
9 intended to be exhaustive. It should be read in conjunction with the SVE
10 documentation in sve.rst which provides details on the Streaming SVE mode
11 included in SME.
12
13 This document does not aim to describe the SME architecture or programmer's
14 model. To aid understanding, a minimal description of relevant programmer's
15 model features for SME is included in Appendix A.
16
17
18 1. General
19 -----------
20
21 * PSTATE.SM, PSTATE.ZA, the streaming mode vector length, the ZA and (when
22 present) ZTn register state and TPIDR2_EL0 are tracked per thread.
23
24 * The presence of SME is reported to userspace via HWCAP2_SME in the aux vector
25 AT_HWCAP2 entry. Presence of this flag implies the presence of the SME
26 instructions and registers, and the Linux-specific system interfaces
27 described in this document. SME is reported in /proc/cpuinfo as "sme".
28
29 * The presence of SME2 is reported to userspace via HWCAP2_SME2 in the
30 aux vector AT_HWCAP2 entry. Presence of this flag implies the presence of
31 the SME2 instructions and ZT0, and the Linux-specific system interfaces
32 described in this document. SME2 is reported in /proc/cpuinfo as "sme2".
33
34 * Support for the execution of SME instructions in userspace can also be
35 detected by reading the CPU ID register ID_AA64PFR1_EL1 using an MRS
36 instruction, and checking that the value of the SME field is nonzero. [3]
37
38 It does not guarantee the presence of the system interfaces described in the
39 following sections: software that needs to verify that those interfaces are
40 present must check for HWCAP2_SME instead.
41
42 * There are a number of optional SME features, presence of these is reported
43 through AT_HWCAP2 through:
44
45 HWCAP2_SME_I16I64
46 HWCAP2_SME_F64F64
47 HWCAP2_SME_I8I32
48 HWCAP2_SME_F16F32
49 HWCAP2_SME_B16F32
50 HWCAP2_SME_F32F32
51 HWCAP2_SME_FA64
52 HWCAP2_SME2
53
54 This list may be extended over time as the SME architecture evolves.
55
56 These extensions are also reported via the CPU ID register ID_AA64SMFR0_EL1,
57 which userspace can read using an MRS instruction. See elf_hwcaps.txt and
58 cpu-feature-registers.txt for details.
59
60 * Debuggers should restrict themselves to interacting with the target via the
61 NT_ARM_SVE, NT_ARM_SSVE, NT_ARM_ZA and NT_ARM_ZT regsets. The recommended
62 way of detecting support for these regsets is to connect to a target process
63 first and then attempt a
64
65 ptrace(PTRACE_GETREGSET, pid, NT_ARM_<regset>, &iov).
66
67 * Whenever ZA register values are exchanged in memory between userspace and
68 the kernel, the register value is encoded in memory as a series of horizontal
69 vectors from 0 to VL/8-1 stored in the same endianness invariant format as is
70 used for SVE vectors.
71
72 * On thread creation PSTATE.ZA and TPIDR2_EL0 are preserved unless CLONE_VM
73 is specified, in which case PSTATE.ZA is set to 0 and TPIDR2_EL0 is set to 0.
74
75 2. Vector lengths
76 ------------------
77
78 SME defines a second vector length similar to the SVE vector length which
79 controls the size of the streaming mode SVE vectors and the ZA matrix array.
80 The ZA matrix is square with each side having as many bytes as a streaming
81 mode SVE vector.
82
83
84 3. System call behaviour
85 -------------------------
86
87 * On syscall PSTATE.ZA is preserved, if PSTATE.ZA==1 then the contents of the
88 ZA matrix and ZTn (if present) are preserved.
89
90 * On syscall PSTATE.SM will be cleared and the SVE registers will be handled
91 as per the standard SVE ABI.
92
93 * None of the SVE registers, ZA or ZTn are used to pass arguments to
94 or receive results from any syscall.
95
96 * On process creation (eg, clone()) the newly created process will have
97 PSTATE.SM cleared.
98
99 * All other SME state of a thread, including the currently configured vector
100 length, the state of the PR_SME_VL_INHERIT flag, and the deferred vector
101 length (if any), is preserved across all syscalls, subject to the specific
102 exceptions for execve() described in section 6.
103
104
105 4. Signal handling
106 -------------------
107
108 * Signal handlers are invoked with PSTATE.SM=0, PSTATE.ZA=0, and TPIDR2_EL0=0.
109
110 * A new signal frame record TPIDR2_MAGIC is added formatted as a struct
111 tpidr2_context to allow access to TPIDR2_EL0 from signal handlers.
112
113 * A new signal frame record za_context encodes the ZA register contents on
114 signal delivery. [1]
115
116 * The signal frame record for ZA always contains basic metadata, in particular
117 the thread's vector length (in za_context.vl).
118
119 * The ZA matrix may or may not be included in the record, depending on
120 the value of PSTATE.ZA. The registers are present if and only if:
121 za_context.head.size >= ZA_SIG_CONTEXT_SIZE(sve_vq_from_vl(za_context.vl))
122 in which case PSTATE.ZA == 1.
123
124 * If matrix data is present, the remainder of the record has a vl-dependent
125 size and layout. Macros ZA_SIG_* are defined [1] to facilitate access to
126 them.
127
128 * The matrix is stored as a series of horizontal vectors in the same format as
129 is used for SVE vectors.
130
131 * If the ZA context is too big to fit in sigcontext.__reserved[], then extra
132 space is allocated on the stack, an extra_context record is written in
133 __reserved[] referencing this space. za_context is then written in the
134 extra space. Refer to [1] for further details about this mechanism.
135
136 * If ZTn is supported and PSTATE.ZA==1 then a signal frame record for ZTn will
137 be generated.
138
139 * The signal record for ZTn has magic ZT_MAGIC (0x5a544e01) and consists of a
140 standard signal frame header followed by a struct zt_context specifying
141 the number of ZTn registers supported by the system, then zt_context.nregs
142 blocks of 64 bytes of data per register.
143
144
145 5. Signal return
146 -----------------
147
148 When returning from a signal handler:
149
150 * If there is no za_context record in the signal frame, or if the record is
151 present but contains no register data as described in the previous section,
152 then ZA is disabled.
153
154 * If za_context is present in the signal frame and contains matrix data then
155 PSTATE.ZA is set to 1 and ZA is populated with the specified data.
156
157 * The vector length cannot be changed via signal return. If za_context.vl in
158 the signal frame does not match the current vector length, the signal return
159 attempt is treated as illegal, resulting in a forced SIGSEGV.
160
161 * If ZTn is not supported or PSTATE.ZA==0 then it is illegal to have a
162 signal frame record for ZTn, resulting in a forced SIGSEGV.
163
164
165 6. prctl extensions
166 --------------------
167
168 Some new prctl() calls are added to allow programs to manage the SME vector
169 length:
170
171 prctl(PR_SME_SET_VL, unsigned long arg)
172
173 Sets the vector length of the calling thread and related flags, where
174 arg == vl | flags. Other threads of the calling process are unaffected.
175
176 vl is the desired vector length, where sve_vl_valid(vl) must be true.
177
178 flags:
179
180 PR_SME_VL_INHERIT
181
182 Inherit the current vector length across execve(). Otherwise, the
183 vector length is reset to the system default at execve(). (See
184 Section 9.)
185
186 PR_SME_SET_VL_ONEXEC
187
188 Defer the requested vector length change until the next execve()
189 performed by this thread.
190
191 The effect is equivalent to implicit execution of the following
192 call immediately after the next execve() (if any) by the thread:
193
194 prctl(PR_SME_SET_VL, arg & ~PR_SME_SET_VL_ONEXEC)
195
196 This allows launching of a new program with a different vector
197 length, while avoiding runtime side effects in the caller.
198
199 Without PR_SME_SET_VL_ONEXEC, the requested change takes effect
200 immediately.
201
202
203 Return value: a nonnegative on success, or a negative value on error:
204 EINVAL: SME not supported, invalid vector length requested, or
205 invalid flags.
206
207
208 On success:
209
210 * Either the calling thread's vector length or the deferred vector length
211 to be applied at the next execve() by the thread (dependent on whether
212 PR_SME_SET_VL_ONEXEC is present in arg), is set to the largest value
213 supported by the system that is less than or equal to vl. If vl ==
214 SVE_VL_MAX, the value set will be the largest value supported by the
215 system.
216
217 * Any previously outstanding deferred vector length change in the calling
218 thread is cancelled.
219
220 * The returned value describes the resulting configuration, encoded as for
221 PR_SME_GET_VL. The vector length reported in this value is the new
222 current vector length for this thread if PR_SME_SET_VL_ONEXEC was not
223 present in arg; otherwise, the reported vector length is the deferred
224 vector length that will be applied at the next execve() by the calling
225 thread.
226
227 * Changing the vector length causes all of ZA, ZTn, P0..P15, FFR and all
228 bits of Z0..Z31 except for Z0 bits [127:0] .. Z31 bits [127:0] to become
229 unspecified, including both streaming and non-streaming SVE state.
230 Calling PR_SME_SET_VL with vl equal to the thread's current vector
231 length, or calling PR_SME_SET_VL with the PR_SME_SET_VL_ONEXEC flag,
232 does not constitute a change to the vector length for this purpose.
233
234 * Changing the vector length causes PSTATE.ZA to be cleared.
235 Calling PR_SME_SET_VL with vl equal to the thread's current vector
236 length, or calling PR_SME_SET_VL with the PR_SME_SET_VL_ONEXEC flag,
237 does not constitute a change to the vector length for this purpose.
238
239
240 prctl(PR_SME_GET_VL)
241
242 Gets the vector length of the calling thread.
243
244 The following flag may be OR-ed into the result:
245
246 PR_SME_VL_INHERIT
247
248 Vector length will be inherited across execve().
249
250 There is no way to determine whether there is an outstanding deferred
251 vector length change (which would only normally be the case between a
252 fork() or vfork() and the corresponding execve() in typical use).
253
254 To extract the vector length from the result, bitwise and it with
255 PR_SME_VL_LEN_MASK.
256
257 Return value: a nonnegative value on success, or a negative value on error:
258 EINVAL: SME not supported.
259
260
261 7. ptrace extensions
262 ---------------------
263
264 * A new regset NT_ARM_SSVE is defined for access to streaming mode SVE
265 state via PTRACE_GETREGSET and PTRACE_SETREGSET, this is documented in
266 sve.rst.
267
268 * A new regset NT_ARM_ZA is defined for ZA state for access to ZA state via
269 PTRACE_GETREGSET and PTRACE_SETREGSET.
270
271 Refer to [2] for definitions.
272
273 The regset data starts with struct user_za_header, containing:
274
275 size
276
277 Size of the complete regset, in bytes.
278 This depends on vl and possibly on other things in the future.
279
280 If a call to PTRACE_GETREGSET requests less data than the value of
281 size, the caller can allocate a larger buffer and retry in order to
282 read the complete regset.
283
284 max_size
285
286 Maximum size in bytes that the regset can grow to for the target
287 thread. The regset won't grow bigger than this even if the target
288 thread changes its vector length etc.
289
290 vl
291
292 Target thread's current streaming vector length, in bytes.
293
294 max_vl
295
296 Maximum possible streaming vector length for the target thread.
297
298 flags
299
300 Zero or more of the following flags, which have the same
301 meaning and behaviour as the corresponding PR_SET_VL_* flags:
302
303 SME_PT_VL_INHERIT
304
305 SME_PT_VL_ONEXEC (SETREGSET only).
306
307 * The effects of changing the vector length and/or flags are equivalent to
308 those documented for PR_SME_SET_VL.
309
310 The caller must make a further GETREGSET call if it needs to know what VL is
311 actually set by SETREGSET, unless is it known in advance that the requested
312 VL is supported.
313
314 * The size and layout of the payload depends on the header fields. The
315 ZA_PT_ZA*() macros are provided to facilitate access to the data.
316
317 * In either case, for SETREGSET it is permissible to omit the payload, in which
318 case the vector length and flags are changed and PSTATE.ZA is set to 0
319 (along with any consequences of those changes). If a payload is provided
320 then PSTATE.ZA will be set to 1.
321
322 * For SETREGSET, if the requested VL is not supported, the effect will be the
323 same as if the payload were omitted, except that an EIO error is reported.
324 No attempt is made to translate the payload data to the correct layout
325 for the vector length actually set. It is up to the caller to translate the
326 payload layout for the actual VL and retry.
327
328 * The effect of writing a partial, incomplete payload is unspecified.
329
330 * A new regset NT_ARM_ZT is defined for access to ZTn state via
331 PTRACE_GETREGSET and PTRACE_SETREGSET.
332
333 * The NT_ARM_ZT regset consists of a single 512 bit register.
334
335 * When PSTATE.ZA==0 reads of NT_ARM_ZT will report all bits of ZTn as 0.
336
337 * Writes to NT_ARM_ZT will set PSTATE.ZA to 1.
338
339 * If any register data is provided along with SME_PT_VL_ONEXEC then the
340 registers data will be interpreted with the current vector length, not
341 the vector length configured for use on exec.
342
343
344 8. ELF coredump extensions
345 ---------------------------
346
347 * NT_ARM_SSVE notes will be added to each coredump for
348 each thread of the dumped process. The contents will be equivalent to the
349 data that would have been read if a PTRACE_GETREGSET of the corresponding
350 type were executed for each thread when the coredump was generated.
351
352 * A NT_ARM_ZA note will be added to each coredump for each thread of the
353 dumped process. The contents will be equivalent to the data that would have
354 been read if a PTRACE_GETREGSET of NT_ARM_ZA were executed for each thread
355 when the coredump was generated.
356
357 * A NT_ARM_ZT note will be added to each coredump for each thread of the
358 dumped process. The contents will be equivalent to the data that would have
359 been read if a PTRACE_GETREGSET of NT_ARM_ZT were executed for each thread
360 when the coredump was generated.
361
362 * The NT_ARM_TLS note will be extended to two registers, the second register
363 will contain TPIDR2_EL0 on systems that support SME and will be read as
364 zero with writes ignored otherwise.
365
366 9. System runtime configuration
367 --------------------------------
368
369 * To mitigate the ABI impact of expansion of the signal frame, a policy
370 mechanism is provided for administrators, distro maintainers and developers
371 to set the default vector length for userspace processes:
372
373 /proc/sys/abi/sme_default_vector_length
374
375 Writing the text representation of an integer to this file sets the system
376 default vector length to the specified value rounded to a supported value
377 using the same rules as for setting vector length via PR_SME_SET_VL.
378
379 The result can be determined by reopening the file and reading its
380 contents.
381
382 At boot, the default vector length is initially set to 32 or the maximum
383 supported vector length, whichever is smaller and supported. This
384 determines the initial vector length of the init process (PID 1).
385
386 Reading this file returns the current system default vector length.
387
388 * At every execve() call, the new vector length of the new process is set to
389 the system default vector length, unless
390
391 * PR_SME_VL_INHERIT (or equivalently SME_PT_VL_INHERIT) is set for the
392 calling thread, or
393
394 * a deferred vector length change is pending, established via the
395 PR_SME_SET_VL_ONEXEC flag (or SME_PT_VL_ONEXEC).
396
397 * Modifying the system default vector length does not affect the vector length
398 of any existing process or thread that does not make an execve() call.
399
400
401 Appendix A. SME programmer's model (informative)
402 =================================================
403
404 This section provides a minimal description of the additions made by SME to the
405 ARMv8-A programmer's model that are relevant to this document.
406
407 Note: This section is for information only and not intended to be complete or
408 to replace any architectural specification.
409
410 A.1. Registers
411 ---------------
412
413 In A64 state, SME adds the following:
414
415 * A new mode, streaming mode, in which a subset of the normal FPSIMD and SVE
416 features are available. When supported EL0 software may enter and leave
417 streaming mode at any time.
418
419 For best system performance it is strongly encouraged for software to enable
420 streaming mode only when it is actively being used.
421
422 * A new vector length controlling the size of ZA and the Z registers when in
423 streaming mode, separately to the vector length used for SVE when not in
424 streaming mode. There is no requirement that either the currently selected
425 vector length or the set of vector lengths supported for the two modes in
426 a given system have any relationship. The streaming mode vector length
427 is referred to as SVL.
428
429 * A new ZA matrix register. This is a square matrix of SVLxSVL bits. Most
430 operations on ZA require that streaming mode be enabled but ZA can be
431 enabled without streaming mode in order to load, save and retain data.
432
433 For best system performance it is strongly encouraged for software to enable
434 ZA only when it is actively being used.
435
436 * A new ZT0 register is introduced when SME2 is present. This is a 512 bit
437 register which is accessible when PSTATE.ZA is set, as ZA itself is.
438
439 * Two new 1 bit fields in PSTATE which may be controlled via the SMSTART and
440 SMSTOP instructions or by access to the SVCR system register:
441
442 * PSTATE.ZA, if this is 1 then the ZA matrix is accessible and has valid
443 data while if it is 0 then ZA can not be accessed. When PSTATE.ZA is
444 changed from 0 to 1 all bits in ZA are cleared.
445
446 * PSTATE.SM, if this is 1 then the PE is in streaming mode. When the value
447 of PSTATE.SM is changed then it is implementation defined if the subset
448 of the floating point register bits valid in both modes may be retained.
449 Any other bits will be cleared.
450
451
452 References
453 ==========
454
455 [1] arch/arm64/include/uapi/asm/sigcontext.h
456 AArch64 Linux signal ABI definitions
457
458 [2] arch/arm64/include/uapi/asm/ptrace.h
459 AArch64 Linux ptrace ABI definitions
460
461 [3] Documentation/arch/arm64/cpu-feature-registers.rst
462

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

개요와 일반 규칙

1-74

이 문서는 ARM Scalable Matrix Extension(SME)을 지원하기 위해 Linux가 사용자 공간에 제공하는 interface를 간략히 설명합니다. 완전한 architecture 설명은 아니며, SME에 포함된 Streaming SVE mode의 세부 사항은 `sve.rst`와 함께 읽어야 합니다. Appendix A에는 이 문서를 이해하는 데 필요한 최소 programmer's model이 있습니다.

`PSTATE.SM`, `PSTATE.ZA`, streaming mode vector length, `ZA`, 지원되는 경우 `ZTn`, 그리고 `TPIDR2_EL0` 상태는 thread별로 추적합니다.

표시보고 경로보장하는 내용
`HWCAP2_SME``AT_HWCAP2`, `/proc/cpuinfo: sme`SME 명령·register와 이 문서의 Linux interface
`HWCAP2_SME2``AT_HWCAP2`, `/proc/cpuinfo: sme2`SME2 명령, `ZT0`, Linux interface
`HWCAP2_SME_I16I64``AT_HWCAP2`Optional SME feature
`HWCAP2_SME_F64F64``AT_HWCAP2`Optional SME feature
`HWCAP2_SME_I8I32``AT_HWCAP2`Optional SME feature
`HWCAP2_SME_F16F32``AT_HWCAP2`Optional SME feature
`HWCAP2_SME_B16F32``AT_HWCAP2`Optional SME feature
`HWCAP2_SME_F32F32``AT_HWCAP2`Optional SME feature
`HWCAP2_SME_FA64``AT_HWCAP2`Optional SME feature
`ID_AA64SMFR0_EL1`EL0 `MRS`Optional extension field; 목록은 향후 확장 가능

`ID_AA64PFR1_EL1.SME`가 0이 아닌지 `MRS`로 읽으면 SME 명령 실행 지원은 찾을 수 있지만 Linux-specific system interface까지 보장하지는 않습니다. 그 interface가 필요하면 반드시 `HWCAP2_SME`를 검사해야 합니다. 자세한 feature register 규칙은 `elf_hwcaps.txt`와 `cpu-feature-registers.txt`를 참조합니다.

Debugger는 대상과 `NT_ARM_SVE`, `NT_ARM_SSVE`, `NT_ARM_ZA`, `NT_ARM_ZT` regset으로만 상호 작용해야 합니다. 지원 여부는 먼저 target process에 연결한 뒤 다음 `PTRACE_GETREGSET`을 시도하는 방식이 권장됩니다.

ptrace(PTRACE_GETREGSET, pid, NT_ARM_<regset>, &iov).

User/kernel 사이에서 `ZA` 값을 memory로 교환할 때는 0부터 `VL/8-1`까지의 horizontal vector 연속으로 encoding하고, SVE vector와 같은 endianness-invariant 형식을 사용합니다.

Thread 생성 시 `PSTATE.ZA`와 `TPIDR2_EL0`는 보존됩니다. 단, `CLONE_VM`을 지정하면 둘 다 0으로 설정합니다.

Streaming vector length

75-83

SME는 SVE vector length와 비슷한 두 번째 vector length를 정의합니다. 이 값은 streaming mode SVE vector와 `ZA` matrix array의 크기를 제어합니다. `ZA`는 정사각형이며 각 변의 byte 수가 streaming mode SVE vector의 byte 수와 같습니다.

System call 동작

84-104

Syscall에서는 `PSTATE.ZA`를 보존합니다. `PSTATE.ZA == 1`이면 `ZA` matrix와 지원되는 `ZTn` 내용도 보존합니다. 반면 `PSTATE.SM`은 clear하고 SVE register는 standard SVE ABI에 따라 처리합니다.

SVE register, `ZA`, `ZTn`은 syscall argument나 return value 전달에 사용하지 않습니다. `clone()` 같은 process 생성 뒤 새 process의 `PSTATE.SM`도 clear됩니다.

현재 vector length, `PR_SME_VL_INHERIT`, deferred vector length를 포함한 다른 SME thread state는 모든 syscall에서 보존됩니다. 예외는 6절에 명시한 `execve()` 규칙뿐입니다.

Signal 전달

105-144

Signal handler는 `PSTATE.SM=0`, `PSTATE.ZA=0`, `TPIDR2_EL0=0` 상태로 호출됩니다. Handler가 이전 값을 읽고 복원할 수 있도록 signal frame에 새 record를 추가합니다.

Record내용존재 조건
`tpidr2_context` / `TPIDR2_MAGIC``TPIDR2_EL0`SME signal frame
`za_context``za_context.vl` metadata와 선택적 `ZA` matrix`head.size >= ZA_SIG_CONTEXT_SIZE(sve_vq_from_vl(vl))`이면 data 포함, 즉 `PSTATE.ZA == 1`
`zt_context` / `ZT_MAGIC (0x5a544e01)``nregs`와 register당 64 bytes`ZTn` 지원 및 `PSTATE.ZA == 1`

Matrix data가 있으면 record의 나머지 size와 layout은 `vl`에 따라 달라지며 `ZA_SIG_*` macro로 접근합니다. Matrix는 SVE vector와 같은 형식의 horizontal vector 연속으로 저장합니다.

`ZA` context가 `sigcontext.__reserved[]`에 들어가지 않으면 stack에 extra space를 할당하고 `__reserved[]`의 `extra_context`가 그 공간을 가리키게 한 뒤 `za_context`를 extra space에 기록합니다.

Signal return

145-164

Signal frame에 `za_context`가 없거나 record에 matrix data가 없으면 `ZA`를 disable합니다. Matrix data가 있으면 `PSTATE.ZA=1`로 만들고 지정한 data로 `ZA`를 채웁니다.

Signal return으로 vector length를 바꿀 수 없습니다. `za_context.vl`이 현재 vector length와 다르면 illegal return으로 처리해 강제 `SIGSEGV`를 발생시킵니다.

`ZTn`을 지원하지 않거나 `PSTATE.ZA == 0`인데 `ZTn` signal record가 있으면 역시 illegal frame이며 강제 `SIGSEGV`가 발생합니다.

prctl vector-length 제어

165-260

`prctl(PR_SME_SET_VL, unsigned long arg)`는 calling thread의 SME vector length와 관련 flag를 설정합니다. `arg == vl | flags`이고 다른 thread에는 영향을 주지 않습니다. `vl`은 `sve_vl_valid(vl)`을 만족해야 합니다.

Flag효과
`PR_SME_VL_INHERIT``execve()` 뒤 현재 vector length 상속; 없으면 system default로 reset
`PR_SME_SET_VL_ONEXEC`요청한 변경을 이 thread의 다음 `execve()` 직후까지 연기

`PR_SME_SET_VL_ONEXEC`의 효과는 다음 호출을 다음 `execve()` 직후 암묵적으로 실행한 것과 같습니다. Caller의 runtime side effect 없이 다른 vector length로 새 program을 시작할 수 있습니다.

prctl(PR_SME_SET_VL, arg & ~PR_SME_SET_VL_ONEXEC)

Flag가 없으면 변경은 즉시 적용됩니다. 성공 시 nonnegative 값을, SME 미지원·invalid vector length·invalid flag이면 `EINVAL`을 반환합니다.

  • 현재 또는 deferred vector length는 system이 지원하는 값 중 요청 `vl` 이하의 가장 큰 값이 됩니다. `vl == SVE_VL_MAX`이면 system 최대값을 선택합니다.
  • 이전에 남아 있던 deferred vector-length change는 취소됩니다.
  • Return value는 `PR_SME_GET_VL` 형식입니다. `ONEXEC`이 없으면 새 현재값, 있으면 다음 `execve()`에 적용할 deferred 값을 보고합니다.
  • 실제 vector length가 바뀌면 `ZA`, `ZTn`, `P0..P15`, `FFR`, 그리고 각 `Z0..Z31`의 `[127:0]` 이외 bit가 streaming/non-streaming state 모두 unspecified가 됩니다.
  • 실제 vector length가 바뀌면 `PSTATE.ZA`를 clear합니다. 현재값과 같은 `vl` 또는 `ONEXEC` 호출은 이 목적에서 변경으로 보지 않습니다.

`prctl(PR_SME_GET_VL)`은 calling thread의 vector length를 반환하고 결과에 `PR_SME_VL_INHERIT`가 OR될 수 있습니다. Outstanding deferred change의 존재는 조회할 수 없습니다. Vector length는 결과를 `PR_SME_VL_LEN_MASK`와 bitwise AND해 추출합니다. SME가 없으면 `EINVAL`입니다.

ptrace regset

261-343

`NT_ARM_SSVE`는 streaming SVE state를 다루며 세부 규칙은 `sve.rst`에 있습니다. `NT_ARM_ZA`는 `PTRACE_GETREGSET`/`PTRACE_SETREGSET`으로 `ZA` state에 접근합니다. 정의는 `arch/arm64/include/uapi/asm/ptrace.h`에 있습니다.

`struct user_za_header` field의미
`size`현재 complete regset byte size; buffer가 작으면 큰 buffer로 재시도
`max_size`Target vector length가 바뀌어도 넘지 않는 최대 byte size
`vl`Target의 현재 streaming vector length(byte)
`max_vl`Target이 가질 수 있는 최대 streaming vector length
`flags``SME_PT_VL_INHERIT`, SETREGSET 전용 `SME_PT_VL_ONEXEC`

Vector length나 flag를 바꾸는 효과는 `PR_SME_SET_VL`과 같습니다. SETREGSET이 실제로 선택한 VL을 알아야 하고 요청값 지원 여부를 미리 모르면 추가 GETREGSET이 필요합니다. Payload size/layout은 header에 의존하며 `ZA_PT_ZA*()` macro로 접근합니다.

Regset/상황ReadWrite
`NT_ARM_ZA`Header와 선택적 ZA payloadPayload 생략 시 `PSTATE.ZA=0`; 제공 시 `PSTATE.ZA=1`
`NT_ARM_ZT``PSTATE.ZA=0`이면 `ZTn` bit를 모두 0으로 보고512-bit register data를 쓰면 `PSTATE.ZA=1`
지원하지 않는 VL-Payload 생략과 같은 상태 변경 후 `EIO`; caller가 실제 VL layout으로 변환해 재시도

Partial/incomplete payload의 효과는 unspecified입니다. `SME_PT_VL_ONEXEC`과 register data를 함께 주면 data는 exec용 deferred VL이 아니라 현재 vector length로 해석합니다.

ELF coredump

344-365

Dump되는 process의 각 thread마다 ptrace에서 읽을 수 있는 것과 같은 state를 ELF note로 기록합니다.

Note내용
`NT_ARM_SSVE`Streaming-mode SVE state
`NT_ARM_ZA``PTRACE_GETREGSET(NT_ARM_ZA)`와 같은 ZA state
`NT_ARM_ZT``PTRACE_GETREGSET(NT_ARM_ZT)`와 같은 ZTn state
`NT_ARM_TLS`두 register로 확장; SME system의 두 번째 register는 `TPIDR2_EL0`, 미지원 system은 read 0/write 무시

System runtime configuration

366-400

Signal frame 확장의 ABI 영향을 줄이기 위해 administrator, distribution maintainer, developer가 사용자 process의 default vector length를 정하는 policy file을 제공합니다: `/proc/sys/abi/sme_default_vector_length`.

정수를 쓰면 `PR_SME_SET_VL`과 같은 규칙으로 지원 가능한 값에 round하여 system default를 정합니다. File을 다시 열어 읽으면 결과를 확인할 수 있습니다. Boot 초기값은 32와 지원 최대 vector length 중 더 작으면서 지원되는 값이며 init process(PID 1)의 초기값이 됩니다.

각 `execve()`에서 새 process는 system default를 받습니다. 단, caller에 `PR_SME_VL_INHERIT` 또는 `SME_PT_VL_INHERIT`가 있거나 `PR_SME_SET_VL_ONEXEC`/`SME_PT_VL_ONEXEC`으로 deferred change가 있으면 예외입니다. Default 변경은 이후 `execve()`를 하지 않는 기존 process와 thread에 영향을 주지 않습니다.

Appendix A와 참고 자료

401-461

Appendix A는 SME가 ARMv8-A programmer's model에 추가한 최소 사항만 설명하며 architecture specification을 대체하지 않습니다.

상태크기/제어핵심 동작
Streaming mode`PSTATE.SM`Normal FPSIMD/SVE의 subset; 사용 중일 때만 enable 권장
Streaming vector length`SVL`Streaming `Z`와 `ZA` 크기; normal SVE VL과 독립
`ZA``SVL x SVL` bits대부분 streaming mode 필요; load/save/retain에는 mode 없이 enable 가능
`ZT0`512 bitsSME2에서 추가되고 `PSTATE.ZA=1`일 때 접근
`PSTATE.ZA`1 bit0→1 전환 시 `ZA` 모든 bit clear
`PSTATE.SM`1 bit변경 시 두 mode 공통 FP bit 보존 여부는 implementation-defined, 나머지는 clear

Software는 `SMSTART`, `SMSTOP` 또는 `SVCR` system register로 `PSTATE.SM`과 `PSTATE.ZA`를 제어합니다. 성능을 위해 streaming mode와 `ZA`는 실제 사용 중일 때만 enable하는 것이 강하게 권장됩니다.

Reference내용
`arch/arm64/include/uapi/asm/sigcontext.h`AArch64 Linux signal ABI
`arch/arm64/include/uapi/asm/ptrace.h`AArch64 Linux ptrace ABI
`Documentation/arch/arm64/cpu-feature-registers.rst`CPU feature register interface