Skip to contentSkip to conversation

x86/paravirt: Remove trailing semicolons from alternative asm templates

PATCH RESEND Superseded Uros Bizjak 4 participants 7 messages Jan 5 – Jan 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/2 x86/paravirt: Remove trailing semicolons from alternative asm templates

GCC inline asm treats semicolons as instruction separators, so a semicolon after the last instruction is not required.

Cc Ajay Kaher <[email protected]>
Cc Alexey Makhalov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/include/asm/paravirt.h       | 20 ++++++++++----------
 arch/x86/include/asm/paravirt_types.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)
arch/x86/include/asm/paravirt.h +10 -10
index b5e59a7ba0d0..4f6ec60b4cb3 100644
@@ -151,7 +151,7 @@ static inline void write_cr0(unsigned long x)
 static __always_inline unsigned long read_cr2(void)
 {
 	return PVOP_ALT_CALLEE0(unsigned long, mmu.read_cr2,
-				"mov %%cr2, %%rax;", ALT_NOT_XEN);
+				"mov %%cr2, %%rax", ALT_NOT_XEN);
 }
 
 static __always_inline void write_cr2(unsigned long x)
@@ -162,7 +162,7 @@ static __always_inline void write_cr2(unsigned long x)
 static inline unsigned long __read_cr3(void)
 {
 	return PVOP_ALT_CALL0(unsigned long, mmu.read_cr3,
-			      "mov %%cr3, %%rax;", ALT_NOT_XEN);
+			      "mov %%cr3, %%rax", ALT_NOT_XEN);
 }
 
 static inline void write_cr3(unsigned long x)
@@ -560,7 +560,7 @@ static __always_inline void pv_queued_spin_lock_slowpath(struct qspinlock *lock,
 static __always_inline void pv_queued_spin_unlock(struct qspinlock *lock)
 {
 	PVOP_ALT_VCALLEE1(lock.queued_spin_unlock, lock,
-			  "movb $0, (%%" _ASM_ARG1 ");",
+			  "movb $0, (%%" _ASM_ARG1 ")",
 			  ALT_NOT(X86_FEATURE_PVUNLOCK));
 }
 
@@ -577,7 +577,7 @@ static __always_inline void pv_kick(int cpu)
 static __always_inline bool pv_vcpu_is_preempted(long cpu)
 {
 	return PVOP_ALT_CALLEE1(bool, lock.vcpu_is_preempted, cpu,
-				"xor %%" _ASM_AX ", %%" _ASM_AX ";",
+				"xor %%" _ASM_AX ", %%" _ASM_AX,
 				ALT_NOT(X86_FEATURE_VCPUPREEMPT));
 }
 
@@ -657,18 +657,18 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
 #ifdef CONFIG_PARAVIRT_XXL
 static __always_inline unsigned long arch_local_save_flags(void)
 {
-	return PVOP_ALT_CALLEE0(unsigned long, irq.save_fl, "pushf; pop %%rax;",
+	return PVOP_ALT_CALLEE0(unsigned long, irq.save_fl, "pushf; pop %%rax",
 				ALT_NOT_XEN);
 }
 
 static __always_inline void arch_local_irq_disable(void)
 {
-	PVOP_ALT_VCALLEE0(irq.irq_disable, "cli;", ALT_NOT_XEN);
+	PVOP_ALT_VCALLEE0(irq.irq_disable, "cli", ALT_NOT_XEN);
 }
 
 static __always_inline void arch_local_irq_enable(void)
 {
-	PVOP_ALT_VCALLEE0(irq.irq_enable, "sti;", ALT_NOT_XEN);
+	PVOP_ALT_VCALLEE0(irq.irq_enable, "sti", ALT_NOT_XEN);
 }
 
 static __always_inline unsigned long arch_local_irq_save(void)
@@ -713,9 +713,9 @@ void native_pv_lock_init(void) __init;
 	call PARA_INDIRECT(pv_ops+PV_IRQ_save_fl);
 .endm
 
-#define SAVE_FLAGS ALTERNATIVE_2 "PARA_IRQ_save_fl;",			\
-				 "ALT_CALL_INSTR;", ALT_CALL_ALWAYS,	\
-				 "pushf; pop %rax;", ALT_NOT_XEN
+#define SAVE_FLAGS ALTERNATIVE_2 "PARA_IRQ_save_fl",			\
+				 "ALT_CALL_INSTR", ALT_CALL_ALWAYS,	\
+				 "pushf; pop %rax", ALT_NOT_XEN
 #endif
 #endif /* CONFIG_PARAVIRT_XXL */
 #endif	/* CONFIG_X86_64 */
arch/x86/include/asm/paravirt_types.h +1 -1
index 3502939415ad..e82dba084198 100644
@@ -250,7 +250,7 @@ extern struct paravirt_patch_template pv_ops;
  */
 #define PARAVIRT_CALL					\
 	ANNOTATE_RETPOLINE_SAFE "\n\t"			\
-	"call *%[paravirt_opptr];"
+	"call *%[paravirt_opptr]"
 
 /*
  * These macros are intended to wrap calls through one of the paravirt
Signature · 1 line
2.52.0
#1 lore raw

PATCH RESEND 2/2 x86/paravirt: Use XOR r32,r32 to clear register in pv_vcpu_is_preempted()

x86_64 zero extends 32bit operations, so for 64bit operands, XOR r32,r32 is functionally equal to XOR r64,r64, but avoids a REX prefix byte when legacy registers are used.

Cc Ajay Kaher <[email protected]>
Cc Alexey Makhalov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/include/asm/paravirt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/paravirt.h +1 -1
index 4f6ec60b4cb3..59aec695ae5f 100644
@@ -577,7 +577,7 @@ static __always_inline void pv_kick(int cpu)
 static __always_inline bool pv_vcpu_is_preempted(long cpu)
 {
 	return PVOP_ALT_CALLEE1(bool, lock.vcpu_is_preempted, cpu,
-				"xor %%" _ASM_AX ", %%" _ASM_AX,
+				"xor %%eax, %%eax",
 				ALT_NOT(X86_FEATURE_VCPUPREEMPT));
 }
 
Signature · 1 line
2.52.0
reviewer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH RESEND 2/2] x86/paravirt: Use XOR r32,r32 to clear register in pv_vcpu_is_preempted()

Quoted 22 lines · Uros Bizjak

x86_64 zero extends 32bit operations, so for 64bit operands, XOR r32,r32 is functionally equal to XOR r64,r64, but avoids a REX prefix byte when legacy registers are used.

Cc Ajay Kaher <[email protected]>
Cc Alexey Makhalov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---
arch/x86/include/asm/paravirt.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/paravirt.h +0 -0
index 4f6ec60b4cb3..59aec695ae5f 100644

arch/x86/include/asm/paravirt.h static __always_inline void pv_kick(int cpu) · line 583

Quoted 8 lines
arch/x86/include/asm/paravirt.h +1 -1
@@ -577,7 +577,7 @@ static __always_inline void pv_kick(int cpu)
 static __always_inline bool pv_vcpu_is_preempted(long cpu)
 {
 	return PVOP_ALT_CALLEE1(bool, lock.vcpu_is_preempted, cpu,
-				"xor %%" _ASM_AX ", %%" _ASM_AX,
+				"xor %%eax, %%eax",
 				ALT_NOT(X86_FEATURE_VCPUPREEMPT));
 }
 
reviewer Acked-by on v1 2/2
#3 lore raw

Re: [PATCH RESEND 2/2] x86/paravirt: Use XOR r32,r32 to clear register in pv_vcpu_is_preempted()

In reply to Uros Bizjak
Quoted 22 lines · Uros Bizjak

x86_64 zero extends 32bit operations, so for 64bit operands, XOR r32,r32 is functionally equal to XOR r64,r64, but avoids a REX prefix byte when legacy registers are used.

Cc Ajay Kaher <[email protected]>
Cc Alexey Makhalov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
  arch/x86/include/asm/paravirt.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/paravirt.h +0 -0
index 4f6ec60b4cb3..59aec695ae5f 100644

arch/x86/include/asm/paravirt.h static __always_inline void pv_kick(int cpu) · line 583

Quoted 8 lines
arch/x86/include/asm/paravirt.h +1 -1
@@ -577,7 +577,7 @@ static __always_inline void pv_kick(int cpu)
  static __always_inline bool pv_vcpu_is_preempted(long cpu)
  {
  	return PVOP_ALT_CALLEE1(bool, lock.vcpu_is_preempted, cpu,
-				"xor %%" _ASM_AX ", %%" _ASM_AX,
+				"xor %%eax, %%eax",
  				ALT_NOT(X86_FEATURE_VCPUPREEMPT));
  }
 
reviewer Acked-by on v1 1/2
#4 lore raw
In reply to Uros Bizjak
Quoted 97 lines · Uros Bizjak

GCC inline asm treats semicolons as instruction separators, so a semicolon after the last instruction is not required.

Cc Ajay Kaher <[email protected]>
Cc Alexey Makhalov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
  arch/x86/include/asm/paravirt.h       | 20 ++++++++++----------
  arch/x86/include/asm/paravirt_types.h |  2 +-
  2 files changed, 11 insertions(+), 11 deletions(-)
arch/x86/include/asm/paravirt.h +10 -10
index b5e59a7ba0d0..4f6ec60b4cb3 100644
@@ -151,7 +151,7 @@ static inline void write_cr0(unsigned long x)
  static __always_inline unsigned long read_cr2(void)
  {
  	return PVOP_ALT_CALLEE0(unsigned long, mmu.read_cr2,
-				"mov %%cr2, %%rax;", ALT_NOT_XEN);
+				"mov %%cr2, %%rax", ALT_NOT_XEN);
  }
 
  static __always_inline void write_cr2(unsigned long x)
@@ -162,7 +162,7 @@ static __always_inline void write_cr2(unsigned long x)
  static inline unsigned long __read_cr3(void)
  {
  	return PVOP_ALT_CALL0(unsigned long, mmu.read_cr3,
-			      "mov %%cr3, %%rax;", ALT_NOT_XEN);
+			      "mov %%cr3, %%rax", ALT_NOT_XEN);
  }
 
  static inline void write_cr3(unsigned long x)
@@ -560,7 +560,7 @@ static __always_inline void pv_queued_spin_lock_slowpath(struct qspinlock *lock,
  static __always_inline void pv_queued_spin_unlock(struct qspinlock *lock)
  {
  	PVOP_ALT_VCALLEE1(lock.queued_spin_unlock, lock,
-			  "movb $0, (%%" _ASM_ARG1 ");",
+			  "movb $0, (%%" _ASM_ARG1 ")",
  			  ALT_NOT(X86_FEATURE_PVUNLOCK));
  }
 
@@ -577,7 +577,7 @@ static __always_inline void pv_kick(int cpu)
  static __always_inline bool pv_vcpu_is_preempted(long cpu)
  {
  	return PVOP_ALT_CALLEE1(bool, lock.vcpu_is_preempted, cpu,
-				"xor %%" _ASM_AX ", %%" _ASM_AX ";",
+				"xor %%" _ASM_AX ", %%" _ASM_AX,
  				ALT_NOT(X86_FEATURE_VCPUPREEMPT));
  }
 
@@ -657,18 +657,18 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
  #ifdef CONFIG_PARAVIRT_XXL
  static __always_inline unsigned long arch_local_save_flags(void)
  {
-	return PVOP_ALT_CALLEE0(unsigned long, irq.save_fl, "pushf; pop %%rax;",
+	return PVOP_ALT_CALLEE0(unsigned long, irq.save_fl, "pushf; pop %%rax",
  				ALT_NOT_XEN);
  }
 
  static __always_inline void arch_local_irq_disable(void)
  {
-	PVOP_ALT_VCALLEE0(irq.irq_disable, "cli;", ALT_NOT_XEN);
+	PVOP_ALT_VCALLEE0(irq.irq_disable, "cli", ALT_NOT_XEN);
  }
 
  static __always_inline void arch_local_irq_enable(void)
  {
-	PVOP_ALT_VCALLEE0(irq.irq_enable, "sti;", ALT_NOT_XEN);
+	PVOP_ALT_VCALLEE0(irq.irq_enable, "sti", ALT_NOT_XEN);
  }
 
  static __always_inline unsigned long arch_local_irq_save(void)
@@ -713,9 +713,9 @@ void native_pv_lock_init(void) __init;
  	call PARA_INDIRECT(pv_ops+PV_IRQ_save_fl);
  .endm
 
-#define SAVE_FLAGS ALTERNATIVE_2 "PARA_IRQ_save_fl;",			\
-				 "ALT_CALL_INSTR;", ALT_CALL_ALWAYS,	\
-				 "pushf; pop %rax;", ALT_NOT_XEN
+#define SAVE_FLAGS ALTERNATIVE_2 "PARA_IRQ_save_fl",			\
+				 "ALT_CALL_INSTR", ALT_CALL_ALWAYS,	\
+				 "pushf; pop %rax", ALT_NOT_XEN
  #endif
  #endif /* CONFIG_PARAVIRT_XXL */
  #endif	/* CONFIG_X86_64 */
arch/x86/include/asm/paravirt_types.h +0 -0
index 3502939415ad..e82dba084198 100644

arch/x86/include/asm/paravirt_types.h extern struct paravirt_patch_template pv_ops; · line 256

Quoted 8 lines
arch/x86/include/asm/paravirt_types.h +1 -1
@@ -250,7 +250,7 @@ extern struct paravirt_patch_template pv_ops;
   */
  #define PARAVIRT_CALL					\
  	ANNOTATE_RETPOLINE_SAFE "\n\t"			\
-	"call *%[paravirt_opptr];"
+	"call *%[paravirt_opptr]"
 
  /*
   * These macros are intended to wrap calls through one of the paravirt
maintainer
#5 lore raw
In reply to Uros Bizjak
Quoted 12 lines · Uros Bizjak

GCC inline asm treats semicolons as instruction separators, so a semicolon after the last instruction is not required.

Cc Ajay Kaher <[email protected]>
Cc Alexey Makhalov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Quoted 4 lines
---
 arch/x86/include/asm/paravirt.h       | 20 ++++++++++----------
 arch/x86/include/asm/paravirt_types.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

Those don't apply anymore. Please rebase them against latest tip/master branch.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#6 lore raw
Quoted 19 lines · Borislav Petkov
Quoted 12 lines · Uros Bizjak

GCC inline asm treats semicolons as instruction separators, so a semicolon after the last instruction is not required.

Cc Ajay Kaher <[email protected]>
Cc Alexey Makhalov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Quoted 4 lines
---
 arch/x86/include/asm/paravirt.h       | 20 ++++++++++----------
 arch/x86/include/asm/paravirt_types.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)
Quoted 2 lines

Those don't apply anymore. Please rebase them against latest tip/master branch.

The rebased series was sent and can be also found at [1].

[1] https://lore.kernel.org/lkml/[email protected]/

Thanks,
Uros.