Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Mark Rutland <mark.rutland@arm.com>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev
Cc: broonie@kernel.org, catalin.marinas@arm.com, james.morse@arm.com,
	maz@kernel.org, oupton@kernel.org, tabba@google.com,
	will@kernel.org
Subject: Re: [PATCH 09/18] arm64: fpsimd: Move sve_get_vl() and sme_get_vl() inline
Date: Wed, 27 May 2026 14:18:16 +0100	[thread overview]
Message-ID: <4aeb92a2-e64e-4969-8588-88d780e4e54a@arm.com> (raw)
In-Reply-To: <20260521132556.584676-10-mark.rutland@arm.com>

On 5/21/26 14:25, Mark Rutland wrote:
> The sve_get_vl() and sme_get_vl() functions are wrappers for the RDVL
> and RDSVL instructions respectively. There's no need for those to be
> out-of-line.
> 
> Replace the out-of-line assembly functions with equivalent inline
> functions.
> 
> The _sve_rdvl assembly macro is unused, and so it is removed. The
> _sme_rdsvl assembly macro is still used elsewhere, and so is kept for
> now.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Fuad Tabba <tabba@google.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Oliver Upton <oupton@kernel.org>
> Cc: Will Deacon <will@kernel.org>
> ---
>  arch/arm64/include/asm/fpsimd.h       | 31 +++++++++++++++++++++++++--
>  arch/arm64/include/asm/fpsimdmacros.h |  6 ------
>  arch/arm64/kernel/entry-fpsimd.S      | 10 ---------
>  3 files changed, 29 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
> index 8efa3c0402a7a..36cf528e64971 100644
> --- a/arch/arm64/include/asm/fpsimd.h
> +++ b/arch/arm64/include/asm/fpsimd.h
> @@ -22,6 +22,9 @@
>  #include <linux/stddef.h>
>  #include <linux/types.h>
>  
> +#define __SVE_PREAMBLE		".arch_extension sve\n"
> +#define __SME_PREAMBLE		".arch_extension sme\n"
> +
>  /* Masks for extracting the FPSR and FPCR from the FPSCR */
>  #define VFP_FPSCR_STAT_MASK	0xf800009f
>  #define VFP_FPSCR_CTRL_MASK	0x07f79f00
> @@ -141,11 +144,23 @@ static inline void *thread_zt_state(struct thread_struct *thread)
>  	return thread->sme_state + ZA_SIG_REGS_SIZE(sme_vq);
>  }
>  
> +static inline unsigned int sve_get_vl(void)
> +{
> +	unsigned int vl;
> +
> +	asm volatile(
> +	__SVE_PREAMBLE
> +	"	rdvl %x[vl], #1\n"
> +	: [vl] "=r" (vl)
> +	);
> +
> +	return vl;
> +}
> +
>  extern void sve_save_state(void *state, u32 *pfpsr, int save_ffr);
>  extern void sve_load_state(void const *state, u32 const *pfpsr,
>  			   int restore_ffr);
>  extern void sve_flush_live(bool flush_ffr, unsigned long vq_minus_1);
> -extern unsigned int sve_get_vl(void);
>  extern void sme_save_state(void *state, int zt);
>  extern void sme_load_state(void const *state, int zt);
>  
> @@ -400,8 +415,20 @@ static inline int sme_max_virtualisable_vl(void)
>  	return vec_max_virtualisable_vl(ARM64_VEC_SME);
>  }
>  
> +static inline unsigned int sme_get_vl(void)
> +{
> +	unsigned int vl;
> +
> +	asm volatile(
> +	__SME_PREAMBLE
> +	"	rdsvl %x[vl], #1\n"
> +	: [vl] "=r" (vl)
> +	);
> +
> +	return vl;
> +}
> +
>  extern void sme_alloc(struct task_struct *task, bool flush);
> -extern unsigned int sme_get_vl(void);
>  extern int sme_set_current_vl(unsigned long arg);
>  extern int sme_get_current_vl(void);
>  extern void sme_suspend_exit(void);
> diff --git a/arch/arm64/include/asm/fpsimdmacros.h b/arch/arm64/include/asm/fpsimdmacros.h
> index d0bdbbf2d44ad..d75c9d4c9989b 100644
> --- a/arch/arm64/include/asm/fpsimdmacros.h
> +++ b/arch/arm64/include/asm/fpsimdmacros.h
> @@ -125,12 +125,6 @@
>  	ldr p\np, [x\nxbase, #\offset, MUL VL]
>  .endm
>  
> -/* RDVL X\nx, #\imm */
> -.macro _sve_rdvl nx, imm
> -	.arch_extension sve
> -	rdvl x\nx, #\imm
> -.endm
> -
>  /* RDFFR (unpredicated): RDFFR P\np.B */
>  .macro _sve_rdffr np
>  	.arch_extension sve
> diff --git a/arch/arm64/kernel/entry-fpsimd.S b/arch/arm64/kernel/entry-fpsimd.S
> index 88c555745b584..7f2d31dff8c17 100644
> --- a/arch/arm64/kernel/entry-fpsimd.S
> +++ b/arch/arm64/kernel/entry-fpsimd.S
> @@ -57,11 +57,6 @@ SYM_FUNC_START(sve_load_state)
>  	ret
>  SYM_FUNC_END(sve_load_state)
>  
> -SYM_FUNC_START(sve_get_vl)
> -	_sve_rdvl	0, 1
> -	ret
> -SYM_FUNC_END(sve_get_vl)
> -
>  /*
>   * Zero all SVE registers but the first 128-bits of each vector
>   *
> @@ -84,11 +79,6 @@ SYM_FUNC_END(sve_flush_live)
>  
>  #ifdef CONFIG_ARM64_SME
>  
> -SYM_FUNC_START(sme_get_vl)
> -	_sme_rdsvl	0, 1
> -	ret
> -SYM_FUNC_END(sme_get_vl)
> -
>  /*
>   * Save the ZA and ZT state
>   *
> -- 2.30.2
> 

FWIW,

Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>



  parent reply	other threads:[~2026-05-27 13:18 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 13:25 [PATCH 00/18] arm64+KVM: FPSIMD/SVE/SME cleanups Mark Rutland
2026-05-21 13:25 ` [PATCH 01/18] KVM: arm64: Don't include <asm/fpsimdmacros.h> Mark Rutland
2026-05-26 14:18   ` Mark Brown
2026-05-27 10:10   ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 02/18] KVM: arm64: Don't override FFR save/restore argument Mark Rutland
2026-05-26 14:27   ` Mark Brown
2026-05-27 10:16   ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 03/18] KVM: arm64: pkvm: Save host FPMR in host cpu context Mark Rutland
2026-05-27 10:29   ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 04/18] KVM: arm64: pkvm: Remove struct cpu_sve_state Mark Rutland
2026-05-27 11:58   ` Vladimir Murzin
2026-05-27 16:02     ` Mark Rutland
2026-05-27 16:11       ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 05/18] arm64: fpsimd: Fold sve_init_regs() into do_sve_acc() Mark Rutland
2026-05-26 15:28   ` Mark Brown
2026-05-27 12:05   ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 06/18] arm64: fpsimd: Remove sve_set_vq() and sme_set_vq() Mark Rutland
2026-05-26 15:42   ` Mark Brown
2026-05-27 12:50   ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 07/18] arm64: fpsimd: Use assembler for SVE instructions Mark Rutland
2026-05-26 15:43   ` Mark Brown
2026-05-27 12:58   ` Vladimir Murzin
2026-05-27 16:10     ` Mark Rutland
2026-05-21 13:25 ` [PATCH 08/18] arm64: fpsimd: Use assembler for baseline SME instructions Mark Rutland
2026-05-26 15:45   ` Mark Brown
2026-05-27 13:06   ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 09/18] arm64: fpsimd: Move sve_get_vl() and sme_get_vl() inline Mark Rutland
2026-05-26 15:47   ` Mark Brown
2026-05-27 13:18   ` Vladimir Murzin [this message]
2026-05-21 13:25 ` [PATCH 10/18] arm64: sysreg: Add FPCR and FPSR Mark Rutland
2026-05-26 15:55   ` Mark Brown
2026-05-26 16:51     ` Mark Rutland
2026-05-26 16:54       ` Mark Brown
2026-05-21 13:25 ` [PATCH 11/18] arm64: fpsimd: Split FPSR/FPCR from SVE save/restore Mark Rutland
2026-05-26 16:28   ` Mark Brown
2026-05-27 13:51     ` Mark Rutland
2026-05-27 14:13       ` Mark Brown
2026-05-27 16:13         ` Mark Rutland
2026-05-27 13:44   ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 12/18] arm64: fpsimd: Move fpsimd save/restore inline Mark Rutland
2026-05-26 16:44   ` Mark Brown
2026-05-27 14:49   ` Vladimir Murzin
2026-05-27 15:34     ` Mark Rutland
2026-05-27 16:13       ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 13/18] arm64: fpsimd: Use opaque type for SVE state Mark Rutland
2026-05-26 16:53   ` Mark Brown
2026-05-21 13:25 ` [PATCH 14/18] arm64: fpsimd: Use opaque type for SME state Mark Rutland
2026-05-26 16:56   ` Mark Brown
2026-05-21 13:25 ` [PATCH 15/18] arm64: fpsimd: Move SVE save/restore inline Mark Rutland
2026-05-27 12:29   ` Mark Brown
2026-05-21 13:25 ` [PATCH 16/18] arm64: fpsimd: Move sve_flush_live() inline Mark Rutland
2026-05-27 12:54   ` Mark Brown
2026-05-27 16:23     ` Mark Rutland
2026-05-21 13:25 ` [PATCH 17/18] arm64: fpsimd: Move SME save/restore inline Mark Rutland
2026-05-26 14:08   ` Mark Rutland
2026-05-26 14:39     ` Vladimir Murzin
2026-05-26 15:28       ` Mark Rutland
2026-05-26 16:38         ` Mark Rutland
2026-05-27  9:00           ` Vladimir Murzin
2026-05-21 13:25 ` [PATCH 18/18] arm64: fpsimd: Remove <asm/fpsimdmacros.h> Mark Rutland
2026-05-27  8:07 ` [PATCH 00/18] arm64+KVM: FPSIMD/SVE/SME cleanups Marc Zyngier
2026-05-27 10:32   ` Mark Rutland
2026-05-27 14:36     ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4aeb92a2-e64e-4969-8588-88d780e4e54a@arm.com \
    --to=vladimir.murzin@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=tabba@google.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox