We should use system_supports_tpidr2() for TPIDR2 handling.
And this series update some comments for sigcontext and ARM SME.
Dongxu Sun (4):
arm64/signal: Use system_supports_tpidr2() to check TPIDR2
arm64/signal: Alloc tpidr2 sigframe after checking
system_supports_tpidr2()
arm64/signal: Add tpidr2/za/zt sigframe size in comment
arm64/sme: Fix some comments of ARM SME
arch/arm64/include/uapi/asm/sigcontext.h | 5 ++++-
arch/arm64/kernel/fpsimd.c | 4 ++--
arch/arm64/kernel/signal.c | 18 ++++++++++--------
3 files changed, 16 insertions(+), 11 deletions(-)
--
2.33.0
Since commit a9d6915859501("arm64/sme: Implement support
for TPIDR2"), We introduced system_supports_tpidr2() for
TPIDR2 handling. Let's use the specific check instead.
No functional changes.
Signed-off-by: Dongxu Sun <[email protected]>
---
arch/arm64/kernel/signal.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 06a02707f488..032e97f8cae0 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -651,7 +651,7 @@ static int parse_user_sigframe(struct user_ctxs *user,
break;
case TPIDR2_MAGIC:
- if (!system_supports_sme())
+ if (!system_supports_tpidr2())
goto invalid;
if (user->tpidr2)
@@ -802,7 +802,7 @@ static int restore_sigframe(struct pt_regs *regs,
err = restore_fpsimd_context(&user);
}
- if (err == 0 && system_supports_sme() && user.tpidr2)
+ if (err == 0 && system_supports_tpidr2() && user.tpidr2)
err = restore_tpidr2_context(&user);
if (err == 0 && system_supports_sme() && user.za)
@@ -974,7 +974,7 @@ static int setup_sigframe(struct rt_sigframe_user_layout *user,
}
/* TPIDR2 if supported */
- if (system_supports_sme() && err == 0) {
+ if (system_supports_tpidr2() && err == 0) {
struct tpidr2_context __user *tpidr2_ctx =
apply_user_offset(user, user->tpidr2_offset);
err |= preserve_tpidr2_context(tpidr2_ctx);
--
2.33.0
Move tpidr2 sigframe allocation from under the checking of
system_supports_sme() to the checking of system_supports_tpidr2().
Signed-off-by: Dongxu Sun <[email protected]>
---
arch/arm64/kernel/signal.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 032e97f8cae0..2cfc810d0a5b 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -893,6 +893,13 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user,
return err;
}
+ if (system_supports_tpidr2()) {
+ err = sigframe_alloc(user, &user->tpidr2_offset,
+ sizeof(struct tpidr2_context));
+ if (err)
+ return err;
+ }
+
if (system_supports_sme()) {
unsigned int vl;
unsigned int vq = 0;
@@ -902,11 +909,6 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user,
else
vl = task_get_sme_vl(current);
- err = sigframe_alloc(user, &user->tpidr2_offset,
- sizeof(struct tpidr2_context));
- if (err)
- return err;
-
if (thread_za_enabled(¤t->thread))
vq = sve_vq_from_vl(vl);
--
2.33.0
Update the comments of sigcontext.__reserved[], since we already
support SME/SME2.
Signed-off-by: Dongxu Sun <[email protected]>
---
arch/arm64/include/uapi/asm/sigcontext.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/uapi/asm/sigcontext.h b/arch/arm64/include/uapi/asm/sigcontext.h
index 656a10ea6c67..d85e3079474d 100644
--- a/arch/arm64/include/uapi/asm/sigcontext.h
+++ b/arch/arm64/include/uapi/asm/sigcontext.h
@@ -45,10 +45,13 @@ struct sigcontext {
* 0x210 fpsimd_context
* 0x10 esr_context
* 0x8a0 sve_context (vl <= 64) (optional)
+ * 0x10 tpidr2_context (optional)
+ * 0x10 za_context (optional)
+ * 0x10 zt_context (optional)
* 0x20 extra_context (optional)
* 0x10 terminator (null _aarch64_ctx)
*
- * 0x510 (reserved for future allocation)
+ * 0x4e0 (reserved for future allocation)
*
* New records that can exceed this space need to be opt-in for userspace, so
* that an expanded signal frame is not generated unexpectedly. The mechanism
--
2.33.0
When TIF_SME is clear, fpsimd_restore_current_state will disable
SME trap during ret_to_user, then SME access trap is impossible
in userspace, not SVE.
Besides, fix typo: alocated->allocated.
Signed-off-by: Dongxu Sun <[email protected]>
---
arch/arm64/kernel/fpsimd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 692dfefbe0ed..41b8f2052689 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -299,7 +299,7 @@ void task_set_vl_onexec(struct task_struct *task, enum vec_type type,
/*
* TIF_SME controls whether a task can use SME without trapping while
* in userspace, when TIF_SME is set then we must have storage
- * alocated in sve_state and sme_state to store the contents of both ZA
+ * allocated in sve_state and sme_state to store the contents of both ZA
* and the SVE registers for both streaming and non-streaming modes.
*
* If both SVCR.ZA and SVCR.SM are disabled then at any point we
@@ -1477,7 +1477,7 @@ void do_sve_acc(unsigned long esr, struct pt_regs *regs)
*
* TIF_SME should be clear on entry: otherwise, fpsimd_restore_current_state()
* would have disabled the SME access trap for userspace during
- * ret_to_user, making an SVE access trap impossible in that case.
+ * ret_to_user, making an SME access trap impossible in that case.
*/
void do_sme_acc(unsigned long esr, struct pt_regs *regs)
{
--
2.33.0
On Fri, Mar 17, 2023 at 08:49:12PM +0800, Dongxu Sun wrote:
> Since commit a9d6915859501("arm64/sme: Implement support
> for TPIDR2"), We introduced system_supports_tpidr2() for
> TPIDR2 handling. Let's use the specific check instead.
Reviewed-by: Mark Brown <[email protected]>
On Fri, Mar 17, 2023 at 08:49:13PM +0800, Dongxu Sun wrote:
> Move tpidr2 sigframe allocation from under the checking of
> system_supports_sme() to the checking of system_supports_tpidr2().
Reviewed-by: Mark Brown <[email protected]>
I didn't check the context enough to confirm if this may reorder things
in the sigframe but given that we don't have shipping hardware yet and
the layout is generally subject to change I think that's fine.
On Fri, Mar 17, 2023 at 08:49:14PM +0800, Dongxu Sun wrote:
> * 0x8a0 sve_context (vl <= 64) (optional)
> + * 0x10 tpidr2_context (optional)
> + * 0x10 za_context (optional)
The size of the ZA context is variable, going with what the SVE has a VL
which might fit into the base context should be included but that's
complicated what with it likely appearing after another variably sized
frame.
> + * 0x10 zt_context (optional)
The ZT context is never this small, it's always got register contents if
present.
> * 0x20 extra_context (optional)
> * 0x10 terminator (null _aarch64_ctx)
> *
> - * 0x510 (reserved for future allocation)
> + * 0x4e0 (reserved for future allocation)
TBH I'm not sure this comment is actually useful or helpful, it's
already not fully taking into account the variablility of the SVE frame
size (quoting a fixed value) and with the way we allocate things once
we've gone into the extra_context we'll allocate new frames from there
so even smaller frames like the tpidr2_context will go there. I'm not
sure trying to suggest a layout/ordering is clarifying anything for
anyone.
On Fri, Mar 17, 2023 at 08:49:15PM +0800, Dongxu Sun wrote:
> When TIF_SME is clear, fpsimd_restore_current_state will disable
> SME trap during ret_to_user, then SME access trap is impossible
> in userspace, not SVE.
Reviewed-by: Mark Brown <[email protected]>
On 2023/3/17 21:03, Mark Brown wrote:
> On Fri, Mar 17, 2023 at 08:49:14PM +0800, Dongxu Sun wrote:
>
>> * 0x8a0 sve_context (vl <= 64) (optional)
>> + * 0x10 tpidr2_context (optional)
>> + * 0x10 za_context (optional)
>
> The size of the ZA context is variable, going with what the SVE has a VL
> which might fit into the base context should be included but that's
> complicated what with it likely appearing after another variably sized
> frame.
>
>> + * 0x10 zt_context (optional)
>
> The ZT context is never this small, it's always got register contents if
> present.
The context size of ZA and ZT here is wrong due to oversight. The ZA context size is related to the SVL, and the ZT context size may also get changed with further extensions.
>
>> * 0x20 extra_context (optional)
>> * 0x10 terminator (null _aarch64_ctx)
>> *
>> - * 0x510 (reserved for future allocation)
>> + * 0x4e0 (reserved for future allocation)
>
> TBH I'm not sure this comment is actually useful or helpful, it's
> already not fully taking into account the variablility of the SVE frame
> size (quoting a fixed value) and with the way we allocate things once
> we've gone into the extra_context we'll allocate new frames from there
> so even smaller frames like the tpidr2_context will go there. I'm not
> sure trying to suggest a layout/ordering is clarifying anything for
> anyone.
Thanks for your point, considering the scalability of SME/SME2, maybe there is no need to add layout suggestion. So, let's discard this commit:)
Thanks,
Dongxu
On Fri, 17 Mar 2023 20:49:11 +0800, Dongxu Sun wrote:
> We should use system_supports_tpidr2() for TPIDR2 handling.
> And this series update some comments for sigcontext and ARM SME.
>
> Dongxu Sun (4):
> arm64/signal: Use system_supports_tpidr2() to check TPIDR2
> arm64/signal: Alloc tpidr2 sigframe after checking
> system_supports_tpidr2()
> arm64/signal: Add tpidr2/za/zt sigframe size in comment
> arm64/sme: Fix some comments of ARM SME
>
> [...]
Applied patches 1, 2 and 4 to arm64 (for-next/misc), thanks!
[1/4] arm64/signal: Use system_supports_tpidr2() to check TPIDR2
https://git.kernel.org/arm64/c/e9d14f3f3fb7
[2/4] arm64/signal: Alloc tpidr2 sigframe after checking system_supports_tpidr2()
https://git.kernel.org/arm64/c/19e99e7d59bc
[4/4] arm64/sme: Fix some comments of ARM SME
https://git.kernel.org/arm64/c/97b5576b0116
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev