diff mbox series

[RFC,v2,6/8] arm64/sve: Implement an helper to load SVE registers from FPSIMD state

Message ID 20190613161656.20765-7-julien.grall@arm.com (mailing list archive)
State RFC
Headers show
Series arm64/sve: First steps towards optimizing syscalls | expand

Commit Message

Julien Grall June 13, 2019, 4:16 p.m. UTC
In a follow-up patch, we may save the FPSIMD rather than the full SVE
state when the state has to be zeroed on return to userspace (e.g
during a syscall).

Introduce an helper to load SVE vectors from FPSIMD state and zero the rest
of SVE registers.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 arch/arm64/include/asm/fpsimd.h  |  3 +++
 arch/arm64/kernel/entry-fpsimd.S | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

Comments

Dave Martin June 21, 2019, 3:33 p.m. UTC | #1
On Thu, Jun 13, 2019 at 05:16:54PM +0100, Julien Grall wrote:
> In a follow-up patch, we may save the FPSIMD rather than the full SVE
> state when the state has to be zeroed on return to userspace (e.g
> during a syscall).
> 
> Introduce an helper to load SVE vectors from FPSIMD state and zero the rest
> of SVE registers.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> ---
>  arch/arm64/include/asm/fpsimd.h  |  3 +++
>  arch/arm64/kernel/entry-fpsimd.S | 17 +++++++++++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
> index fda3544c9606..f07a88552588 100644
> --- a/arch/arm64/include/asm/fpsimd.h
> +++ b/arch/arm64/include/asm/fpsimd.h
> @@ -86,6 +86,9 @@ extern void sve_load_state(void const *state, u32 const *pfpsr,
>  
>  extern void sve_flush_live(void);
>  
> +extern void sve_load_from_fpsimd_state(struct user_fpsimd_state const *state,
> +				       unsigned long vq_minus_1);
> +

Lose the extra blank line?

>  extern unsigned int sve_get_vl(void);
>  
>  struct arm64_cpu_capabilities;
> diff --git a/arch/arm64/kernel/entry-fpsimd.S b/arch/arm64/kernel/entry-fpsimd.S
> index 17121a51c41f..35c21a707730 100644
> --- a/arch/arm64/kernel/entry-fpsimd.S
> +++ b/arch/arm64/kernel/entry-fpsimd.S
> @@ -58,6 +58,23 @@ ENTRY(sve_get_vl)
>  	ret
>  ENDPROC(sve_get_vl)
>  
> +/*
> + * Load SVE state from FPSIMD state.
> + *
> + * x0 = pointer to struct fpsimd_state
> + * x1 = VQ - 1
> + *
> + * Each SVE vector will be loaded with the first 128-bits taken from FPSIMD
> + * and the rest zeroed. All the other SVE registers will be zeroed.
> + */
> +ENTRY(sve_load_from_fpsimd_state)
> +		sve_load_vq	x1, x2, x3
> +		fpsimd_restore	x0, 8
> + _for n, 0, 15, _sve_pfalse	\n
> +		_sve_wrffr 0
> +		ret
> +ENDPROC(sve_load_from_fpsimd_state)
> +
>  /* Zero all SVE registers but the first 128-bits of each vector */
>  ENTRY(sve_flush_live)
>  	sve_flush

With the extra blank line in fpsimd.h gone (if you agree):

Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Julien Grall June 24, 2019, 4:29 p.m. UTC | #2
Hi Dave,

On 6/21/19 4:33 PM, Dave Martin wrote:
> On Thu, Jun 13, 2019 at 05:16:54PM +0100, Julien Grall wrote:
>> In a follow-up patch, we may save the FPSIMD rather than the full SVE
>> state when the state has to be zeroed on return to userspace (e.g
>> during a syscall).
>>
>> Introduce an helper to load SVE vectors from FPSIMD state and zero the rest
>> of SVE registers.
>>
>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>> ---
>>   arch/arm64/include/asm/fpsimd.h  |  3 +++
>>   arch/arm64/kernel/entry-fpsimd.S | 17 +++++++++++++++++
>>   2 files changed, 20 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
>> index fda3544c9606..f07a88552588 100644
>> --- a/arch/arm64/include/asm/fpsimd.h
>> +++ b/arch/arm64/include/asm/fpsimd.h
>> @@ -86,6 +86,9 @@ extern void sve_load_state(void const *state, u32 const *pfpsr,
>>   
>>   extern void sve_flush_live(void);
>>   
>> +extern void sve_load_from_fpsimd_state(struct user_fpsimd_state const *state,
>> +				       unsigned long vq_minus_1);
>> +
> 
> Lose the extra blank line?
> 
>>   extern unsigned int sve_get_vl(void);
>>   
>>   struct arm64_cpu_capabilities;
>> diff --git a/arch/arm64/kernel/entry-fpsimd.S b/arch/arm64/kernel/entry-fpsimd.S
>> index 17121a51c41f..35c21a707730 100644
>> --- a/arch/arm64/kernel/entry-fpsimd.S
>> +++ b/arch/arm64/kernel/entry-fpsimd.S
>> @@ -58,6 +58,23 @@ ENTRY(sve_get_vl)
>>   	ret
>>   ENDPROC(sve_get_vl)
>>   
>> +/*
>> + * Load SVE state from FPSIMD state.
>> + *
>> + * x0 = pointer to struct fpsimd_state
>> + * x1 = VQ - 1
>> + *
>> + * Each SVE vector will be loaded with the first 128-bits taken from FPSIMD
>> + * and the rest zeroed. All the other SVE registers will be zeroed.
>> + */
>> +ENTRY(sve_load_from_fpsimd_state)
>> +		sve_load_vq	x1, x2, x3
>> +		fpsimd_restore	x0, 8
>> + _for n, 0, 15, _sve_pfalse	\n
>> +		_sve_wrffr 0
>> +		ret
>> +ENDPROC(sve_load_from_fpsimd_state)
>> +
>>   /* Zero all SVE registers but the first 128-bits of each vector */
>>   ENTRY(sve_flush_live)
>>   	sve_flush
> 
> With the extra blank line in fpsimd.h gone (if you agree):

I don't particularly care of the newline :).

> 
> Reviewed-by: Dave Martin <Dave.Martin@arm.com>
> 

Thank you!

Cheers,
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
index fda3544c9606..f07a88552588 100644
--- a/arch/arm64/include/asm/fpsimd.h
+++ b/arch/arm64/include/asm/fpsimd.h
@@ -86,6 +86,9 @@  extern void sve_load_state(void const *state, u32 const *pfpsr,
 
 extern void sve_flush_live(void);
 
+extern void sve_load_from_fpsimd_state(struct user_fpsimd_state const *state,
+				       unsigned long vq_minus_1);
+
 extern unsigned int sve_get_vl(void);
 
 struct arm64_cpu_capabilities;
diff --git a/arch/arm64/kernel/entry-fpsimd.S b/arch/arm64/kernel/entry-fpsimd.S
index 17121a51c41f..35c21a707730 100644
--- a/arch/arm64/kernel/entry-fpsimd.S
+++ b/arch/arm64/kernel/entry-fpsimd.S
@@ -58,6 +58,23 @@  ENTRY(sve_get_vl)
 	ret
 ENDPROC(sve_get_vl)
 
+/*
+ * Load SVE state from FPSIMD state.
+ *
+ * x0 = pointer to struct fpsimd_state
+ * x1 = VQ - 1
+ *
+ * Each SVE vector will be loaded with the first 128-bits taken from FPSIMD
+ * and the rest zeroed. All the other SVE registers will be zeroed.
+ */
+ENTRY(sve_load_from_fpsimd_state)
+		sve_load_vq	x1, x2, x3
+		fpsimd_restore	x0, 8
+ _for n, 0, 15, _sve_pfalse	\n
+		_sve_wrffr 0
+		ret
+ENDPROC(sve_load_from_fpsimd_state)
+
 /* Zero all SVE registers but the first 128-bits of each vector */
 ENTRY(sve_flush_live)
 	sve_flush