[PATCH 15/20] x86/cpu/amd: Use named asm operands in asm_clear_divider()

Josh Poimboeuf posted 20 patches 9 months, 1 week ago
[PATCH 15/20] x86/cpu/amd: Use named asm operands in asm_clear_divider()
Posted by Josh Poimboeuf 9 months, 1 week ago
Use named inline asm operands in preparation for using alternative_io().

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 arch/x86/include/asm/processor.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index a1baf2fc5f9b..b458ff0e4c79 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -709,8 +709,8 @@ static inline u32 per_cpu_l2c_id(unsigned int cpu)
  */
 static __always_inline void amd_clear_divider(void)
 {
-	asm volatile(ALTERNATIVE("", "div %2\n\t", X86_BUG_DIV0)
-		     :: "a" (0), "d" (0), "r" (1));
+	asm volatile(ALTERNATIVE("", "div %[one]\n\t", X86_BUG_DIV0)
+		     :: "a" (0), "d" (0), [one] "r" (1));
 }
 
 extern void amd_check_microcode(void);
-- 
2.48.1
Re: [PATCH 15/20] x86/cpu/amd: Use named asm operands in asm_clear_divider()
Posted by Uros Bizjak 9 months, 1 week ago
On Fri, Mar 14, 2025 at 10:42 PM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
>
> Use named inline asm operands in preparation for using alternative_io().
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> ---
>  arch/x86/include/asm/processor.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> index a1baf2fc5f9b..b458ff0e4c79 100644
> --- a/arch/x86/include/asm/processor.h
> +++ b/arch/x86/include/asm/processor.h
> @@ -709,8 +709,8 @@ static inline u32 per_cpu_l2c_id(unsigned int cpu)
>   */
>  static __always_inline void amd_clear_divider(void)
>  {
> -       asm volatile(ALTERNATIVE("", "div %2\n\t", X86_BUG_DIV0)
> -                    :: "a" (0), "d" (0), "r" (1));
> +       asm volatile(ALTERNATIVE("", "div %[one]\n\t", X86_BUG_DIV0)
> +                    :: "a" (0), "d" (0), [one] "r" (1));

Please remove trailing "\n\t" here and elsewhere.

Thanks,
Uros.
Re: [PATCH 15/20] x86/cpu/amd: Use named asm operands in asm_clear_divider()
Posted by Uros Bizjak 9 months, 1 week ago
On Sat, Mar 15, 2025 at 10:01 AM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> On Fri, Mar 14, 2025 at 10:42 PM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
> >
> > Use named inline asm operands in preparation for using alternative_io().
> >
> > Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> > ---
> >  arch/x86/include/asm/processor.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> > index a1baf2fc5f9b..b458ff0e4c79 100644
> > --- a/arch/x86/include/asm/processor.h
> > +++ b/arch/x86/include/asm/processor.h
> > @@ -709,8 +709,8 @@ static inline u32 per_cpu_l2c_id(unsigned int cpu)
> >   */
> >  static __always_inline void amd_clear_divider(void)
> >  {
> > -       asm volatile(ALTERNATIVE("", "div %2\n\t", X86_BUG_DIV0)
> > -                    :: "a" (0), "d" (0), "r" (1));
> > +       asm volatile(ALTERNATIVE("", "div %[one]\n\t", X86_BUG_DIV0)
> > +                    :: "a" (0), "d" (0), [one] "r" (1));
>
> Please remove trailing "\n\t" here and elsewhere.

Also, please change $subject to mention "amd_clear_divider", not
"asm_clear_divider".

Thanks,
Uros.