Skip to contentSkip to conversation

Various asmlinkage fixes for LTO

PATCH Applied Andi Kleen 9 participants 26 messages Oct 22, 2013 – Oct 30, 2013

Subsystems (8)
Networking Network drivers x86 KVM +4 more subsystems
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

LTO (Link Time Optimization) requires all C symbols used from assembler to be marked visible. This patchkit marks various functions over the tree asmlinkage or __visible, when they are used by assembler.

-Andi

author
#1 lore raw

PATCH 1/11 asmlinkage, kvm: Make kvm_rebooting visible

From: Andi Kleen <[email protected]>

kvm_rebooting is referenced from assembler code, thus needs to be visible.

---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
index a9dd682..6ca3564 100644
@@ -95,7 +95,7 @@ static void hardware_disable_all(void);
 
 static void kvm_io_bus_destroy(struct kvm_io_bus *bus);
 
-bool kvm_rebooting;
+__visible bool kvm_rebooting;
 EXPORT_SYMBOL_GPL(kvm_rebooting);
 
 static bool largepages_enabled = true;
Signature · 1 line
1.8.3.1
Acked-by on v1 1/11
#2 lore raw

Re: [PATCH 01/11] asmlinkage, kvm: Make kvm_rebooting visible

Quoted 9 lines · Andi Kleen

From: Andi Kleen <[email protected]>

kvm_rebooting is referenced from assembler code, thus needs to be visible.

Quoted 19 lines
---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
index a9dd682..6ca3564 100644
@@ -95,7 +95,7 @@ static void hardware_disable_all(void);
 
 static void kvm_io_bus_destroy(struct kvm_io_bus *bus);
 
-bool kvm_rebooting;
+__visible bool kvm_rebooting;
 EXPORT_SYMBOL_GPL(kvm_rebooting);
 
 static bool largepages_enabled = true;
Signature · 1 line
1.8.3.1

--
Gleb.

author
#3 lore raw

PATCH 2/11 asmlinkage: Make __iowrite32_copy visible

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

This is a assembler function on x86, so it should be visible.

---
 include/linux/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/io.h +1 -1
index f4f42fa..8a18e75 100644
@@ -24,7 +24,7 @@
 
 struct device;
 
-void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
+__visible void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
 void __iowrite64_copy(void __iomem *to, const void *from, size_t count);
 
 #ifdef CONFIG_MMU
Signature · 1 line
1.8.3.1
#4 lore raw

Re: [PATCH 02/11] asmlinkage: Make __iowrite32_copy visible

Quoted 9 lines · Andi Kleen

From: Andi Kleen <[email protected]>

This is a assembler function on x86, so it should be visible.

---
 include/linux/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

NAK for this and all the other patches, for two technical reasons:

- Please squash most of these trivial patches into a single patch that also describes the context completely, at least the x86 and core kernel ones that I'd apply within a single maintenance domain.

- Please use the customary changelog style we use in the kernel:

" Current code does (A), this has a problem when (B).
We can improve this doing (C), because (D)."

Just saying 'because of LTO' is not enough, obviously. You need to talk about and explain things Andi. Being cryptic, mysterious and curt might work with some ladies, but it's outright harmful on lkml.

Thanks,

Ingo

author
#5 lore raw

PATCH 3/11 asmlinkage: Make jiffies visible

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

Jiffies is referenced by the linker script, so it has to be visible.

Handled both the generic and the x86 version.

---
 arch/x86/kernel/time.c | 2 +-
 kernel/timer.c         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/time.c +1 -1
index 24d3c91..6ec91c0 100644
@@ -23,7 +23,7 @@
 #include <asm/time.h>
 
 #ifdef CONFIG_X86_64
-DEFINE_VVAR(volatile unsigned long, jiffies) = INITIAL_JIFFIES;
+__visible DEFINE_VVAR(volatile unsigned long, jiffies) = INITIAL_JIFFIES;
 #endif
 
 unsigned long profile_pc(struct pt_regs *regs)
kernel/timer.c +1 -1
index 4296d13..a3ae2da 100644
@@ -52,7 +52,7 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/timer.h>
 
-u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;
+__visible u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;
 
 EXPORT_SYMBOL(jiffies_64);
 
Signature · 1 line
1.8.3.1
author
#6 lore raw

PATCH 4/11 asmlinkage, pnp: Make variables used from assembler code visible

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

Mark variables referenced from assembler files visible.

This fixes compile problems with LTO

---
 drivers/pnp/pnpbios/bioscalls.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/pnp/pnpbios/bioscalls.c +5 -4
index 769d265..deb7f4b 100644
@@ -21,7 +21,7 @@
 
 #include "pnpbios.h"
 
-static struct {
+__visible struct {
 	u16 offset;
 	u16 segment;
 } pnp_bios_callpoint;
@@ -41,6 +41,7 @@ asmlinkage void pnp_bios_callfunc(void);
 
 __asm__(".text			\n"
 	__ALIGN_STR "\n"
+	".globl pnp_bios_callfunc\n"
 	"pnp_bios_callfunc:\n"
 	"	pushl %edx	\n"
 	"	pushl %ecx	\n"
@@ -66,9 +67,9 @@ static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
  * after PnP BIOS oopses.
  */
 
-u32 pnp_bios_fault_esp;
-u32 pnp_bios_fault_eip;
-u32 pnp_bios_is_utter_crap = 0;
+__visible u32 pnp_bios_fault_esp;
+__visible u32 pnp_bios_fault_eip;
+__visible u32 pnp_bios_is_utter_crap = 0;
 
 static spinlock_t pnp_bios_lock;
 
Signature · 1 line
1.8.3.1
author
#7 lore raw

PATCH 5/11 asmlinkage: Make lockdep_sys_exit asmlinkage

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

lockdep_sys_exit can be called from assembler code, so make it asmlinkage

---
 include/linux/lockdep.h | 2 +-
 kernel/lockdep.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/lockdep.h +1 -1
index cfc2f11..18e19e4 100644
@@ -265,7 +265,7 @@ extern void lockdep_info(void);
 extern void lockdep_reset(void);
 extern void lockdep_reset_lock(struct lockdep_map *lock);
 extern void lockdep_free_key_range(void *start, unsigned long size);
-extern void lockdep_sys_exit(void);
+extern asmlinkage void lockdep_sys_exit(void);
 
 extern void lockdep_off(void);
 extern void lockdep_on(void);
kernel/lockdep.c +1 -1
index e16c45b..d3749fe 100644
@@ -4187,7 +4187,7 @@ void debug_show_held_locks(struct task_struct *task)
 }
 EXPORT_SYMBOL_GPL(debug_show_held_locks);
 
-void lockdep_sys_exit(void)
+asmlinkage void lockdep_sys_exit(void)
 {
 	struct task_struct *curr = current;
 
Signature · 1 line
1.8.3.1
author
#8 lore raw

PATCH 6/11 asmlinkage: Make trace_hardirq visible

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

Can be called from assembler code.

---
 kernel/lockdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/lockdep.c +2 -2
index d3749fe..d1a047d 100644
@@ -2555,7 +2555,7 @@ static void __trace_hardirqs_on_caller(unsigned long ip)
 	debug_atomic_inc(hardirqs_on_events);
 }
 
-void trace_hardirqs_on_caller(unsigned long ip)
+__visible void trace_hardirqs_on_caller(unsigned long ip)
 {
 	time_hardirqs_on(CALLER_ADDR0, ip);
 
@@ -2608,7 +2608,7 @@ EXPORT_SYMBOL(trace_hardirqs_on);
 /*
  * Hardirqs were disabled:
  */
-void trace_hardirqs_off_caller(unsigned long ip)
+__visible void trace_hardirqs_off_caller(unsigned long ip)
 {
 	struct task_struct *curr = current;
 
Signature · 1 line
1.8.3.1
maintainer
#9 lore raw

Re: [PATCH 06/11] asmlinkage: Make trace_hardirq visible

Quoted 16 lines · Andi Kleen

From: Andi Kleen <[email protected]>

Can be called from assembler code.

---
 kernel/lockdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/lockdep.c +0 -0
index d3749fe..d1a047d 100644

kernel/lockdep.c static void __trace_hardirqs_on_caller(unsigned long ip) · line 2561

Quoted 8 lines
kernel/lockdep.c +1 -1
@@ -2555,7 +2555,7 @@ static void __trace_hardirqs_on_caller(unsigned long ip)
 	debug_atomic_inc(hardirqs_on_events);
 }
 
-void trace_hardirqs_on_caller(unsigned long ip)
+__visible void trace_hardirqs_on_caller(unsigned long ip)
 {
 	time_hardirqs_on(CALLER_ADDR0, ip);
 

$sub talks about asmlinkage, yet here you insert __visible; 'sup?

author
#10 lore raw

Re: [PATCH 06/11] asmlinkage: Make trace_hardirq visible

Quoted 1 line

$sub talks about asmlinkage, yet here you insert __visible; 'sup?

I use __visible for anything with arguments, because asmlinkage changes the ABI from register to stack on i386.

I still used "asmlinkage" as the generic patch group name as that is more descriptive, and "asmlinkage/visible" would look too ugly.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
author
#11 lore raw

PATCH 7/11 asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

Make the ksymtab symbols for EXPORT_SYMBOL visible. This prevents the LTO compiler from adding a .NUMBER prefix, which avoids various problems in later export processing.

---
 include/linux/export.h | 4 ++--
 scripts/mod/modpost.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/export.h +2 -2
index 412cd50..3f2793d 100644
@@ -43,7 +43,7 @@ extern struct module __this_module;
 /* Mark the CRC weak since genksyms apparently decides not to
  * generate a checksums for some symbols */
 #define __CRC_SYMBOL(sym, sec)					\
-	extern void *__crc_##sym __attribute__((weak));		\
+	extern __visible void *__crc_##sym __attribute__((weak));		\
 	static const unsigned long __kcrctab_##sym		\
 	__used							\
 	__attribute__((section("___kcrctab" sec "+" #sym), unused))	\
@@ -59,7 +59,7 @@ extern struct module __this_module;
 	static const char __kstrtab_##sym[]			\
 	__attribute__((section("__ksymtab_strings"), aligned(1))) \
 	= VMLINUX_SYMBOL_STR(sym);				\
-	static const struct kernel_symbol __ksymtab_##sym	\
+	__visible const struct kernel_symbol __ksymtab_##sym	\
 	__used							\
 	__attribute__((section("___ksymtab" sec "+" #sym), unused))	\
 	= { (unsigned long)&sym, __kstrtab_##sym }
scripts/mod/modpost.c +1 -1
index 8247979..0971bac 100644
@@ -1853,7 +1853,7 @@ static void add_header(struct buffer *b, struct module *mod)
 	buf_printf(b, "\n");
 	buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
 	buf_printf(b, "\n");
-	buf_printf(b, "struct module __this_module\n");
+	buf_printf(b, "__visible struct module __this_module\n");
 	buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
 	buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
 	if (mod->has_init)
Signature · 1 line
1.8.3.1
#12 lore raw

Re: [PATCH 07/11] asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible

Quoted 5 lines · Andi Kleen

From: Andi Kleen <[email protected]>

Make the ksymtab symbols for EXPORT_SYMBOL visible. This prevents the LTO compiler from adding a .NUMBER prefix, which avoids various problems in later export processing.

Applied, thanks.

Cheers,
Rusty.

Quoted 44 lines
---
 include/linux/export.h | 4 ++--
 scripts/mod/modpost.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/export.h +2 -2
index 412cd50..3f2793d 100644
@@ -43,7 +43,7 @@ extern struct module __this_module;
 /* Mark the CRC weak since genksyms apparently decides not to
  * generate a checksums for some symbols */
 #define __CRC_SYMBOL(sym, sec)					\
-	extern void *__crc_##sym __attribute__((weak));		\
+	extern __visible void *__crc_##sym __attribute__((weak));		\
 	static const unsigned long __kcrctab_##sym		\
 	__used							\
 	__attribute__((section("___kcrctab" sec "+" #sym), unused))	\
@@ -59,7 +59,7 @@ extern struct module __this_module;
 	static const char __kstrtab_##sym[]			\
 	__attribute__((section("__ksymtab_strings"), aligned(1))) \
 	= VMLINUX_SYMBOL_STR(sym);				\
-	static const struct kernel_symbol __ksymtab_##sym	\
+	__visible const struct kernel_symbol __ksymtab_##sym	\
 	__used							\
 	__attribute__((section("___ksymtab" sec "+" #sym), unused))	\
 	= { (unsigned long)&sym, __kstrtab_##sym }
scripts/mod/modpost.c +1 -1
index 8247979..0971bac 100644
@@ -1853,7 +1853,7 @@ static void add_header(struct buffer *b, struct module *mod)
 	buf_printf(b, "\n");
 	buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
 	buf_printf(b, "\n");
-	buf_printf(b, "struct module __this_module\n");
+	buf_printf(b, "__visible struct module __this_module\n");
 	buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
 	buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
 	if (mod->has_init)
Signature · 1 line
1.8.3.1
author
#13 lore raw

PATCH 8/11 asmlinkage, mutex: Mark __visible

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

Various kernel/mutex.c functions can be called from inline assembler, so they should be all global and __visible

---
 kernel/mutex.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/mutex.c +5 -5
index 6d647ae..ffba8e9 100644
@@ -67,8 +67,7 @@ EXPORT_SYMBOL(__mutex_init);
  * We also put the fastpath first in the kernel image, to make sure the
  * branch is predicted by the CPU as default-untaken.
  */
-static __used noinline void __sched
-__mutex_lock_slowpath(atomic_t *lock_count);
+__visible void __sched __mutex_lock_slowpath(atomic_t *lock_count);
 
 /**
  * mutex_lock - acquire the mutex
@@ -225,7 +224,8 @@ static inline int mutex_can_spin_on_owner(struct mutex *lock)
 }
 #endif
 
-static __used noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count);
+__visible __used noinline
+void __sched __mutex_unlock_slowpath(atomic_t *lock_count);
 
 /**
  * mutex_unlock - release the mutex
@@ -746,7 +746,7 @@ __mutex_unlock_common_slowpath(atomic_t *lock_count, int nested)
 /*
  * Release the lock, slowpath:
  */
-static __used noinline void
+__visible void
 __mutex_unlock_slowpath(atomic_t *lock_count)
 {
 	__mutex_unlock_common_slowpath(lock_count, 1);
@@ -803,7 +803,7 @@ int __sched mutex_lock_killable(struct mutex *lock)
 }
 EXPORT_SYMBOL(mutex_lock_killable);
 
-static __used noinline void __sched
+__visible void __sched
 __mutex_lock_slowpath(atomic_t *lock_count)
 {
 	struct mutex *lock = container_of(lock_count, struct mutex, count);
Signature · 1 line
1.8.3.1
author
#14 lore raw

PATCH 9/11 asmlinkage: Make main_extable_sort_needed visible

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

main_extable_sort_needed is used by the build system and needs to be a normal ELF symbol. Make it visible so that LTO does not remove or mangle it.

---
 kernel/extable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/extable.c +1 -1
index 832cb28..829afaa 100644
@@ -36,7 +36,7 @@ extern struct exception_table_entry __start___ex_table[];
 extern struct exception_table_entry __stop___ex_table[];
 
 /* Cleared by build time tools if the table is already sorted. */
-u32 __initdata main_extable_sort_needed = 1;
+u32 __initdata __visible main_extable_sort_needed = 1;
 
 /* Sort the kernel's built-in exception table */
 void __init sort_main_extable(void)
Signature · 1 line
1.8.3.1
author
#15 lore raw

PATCH 10/11 asmlinkage: Mark rwsem functions that can be called from assembler asmlinkage

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

---
 lib/rwsem.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/rwsem.c +4 -0
index 19c5fa9..1d66e08 100644
@@ -143,6 +143,7 @@ __rwsem_do_wake(struct rw_semaphore *sem, enum rwsem_wake_type wake_type)
 /*
  * wait for the read lock to be granted
  */
+__visible
 struct rw_semaphore __sched *rwsem_down_read_failed(struct rw_semaphore *sem)
 {
 	long count, adjustment = -RWSEM_ACTIVE_READ_BIAS;
@@ -190,6 +191,7 @@ struct rw_semaphore __sched *rwsem_down_read_failed(struct rw_semaphore *sem)
 /*
  * wait until we successfully acquire the write lock
  */
+__visible
 struct rw_semaphore __sched *rwsem_down_write_failed(struct rw_semaphore *sem)
 {
 	long count, adjustment = -RWSEM_ACTIVE_WRITE_BIAS;
@@ -252,6 +254,7 @@ struct rw_semaphore __sched *rwsem_down_write_failed(struct rw_semaphore *sem)
  * handle waking up a waiter on the semaphore
  * - up_read/up_write has decremented the active part of count if we come here
  */
+__visible
 struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem)
 {
 	unsigned long flags;
@@ -272,6 +275,7 @@ struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem)
  * - caller incremented waiting part of count and discovered it still negative
  * - just wake up any readers at the front of the queue
  */
+__visible
 struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem)
 {
 	unsigned long flags;
Signature · 1 line
1.8.3.1
author
#16 lore raw

PATCH 11/11 asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

- Inline assembler defining C callable code has to be global
- The function has to be visible

Do this in wan/sbni

---
 drivers/net/wan/sbni.c | 6 +++---
 drivers/net/wan/sbni.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wan/sbni.c +3 -3
index 5bbcb5e..571db25 100644
@@ -160,7 +160,7 @@ static int  scandone	__initdata = 0;
 static int  num		__initdata = 0;
 
 static unsigned char  rxl_tab[];
-static u32  crc32tab[];
+__visible u32  sbni_crc32tab[];
 
 /* A list of all installed devices, for removing the driver module. */
 static struct net_device  *sbni_cards[ SBNI_MAX_NUM_CARDS ];
@@ -1563,7 +1563,7 @@ calc_crc32( u32  crc,  u8  *p,  u32  len )
 		"xorl	%%ebx, %%ebx\n"
 		"movl	%2, %%esi\n" 
 		"movl	%3, %%ecx\n" 
-		"movl	$crc32tab, %%edi\n"
+		"movl	$sbni_crc32tab, %%edi\n"
 		"shrl	$2, %%ecx\n"
 		"jz	1f\n"
 
@@ -1645,7 +1645,7 @@ calc_crc32( u32  crc,  u8  *p,  u32  len )
 #endif	/* ASM_CRC */
 
 
-static u32  crc32tab[] __attribute__ ((aligned(8))) = {
+__visible u32  sbni_crc32tab[] __attribute__ ((aligned(8))) = {
 	0xD202EF8D,  0xA505DF1B,  0x3C0C8EA1,  0x4B0BBE37,
 	0xD56F2B94,  0xA2681B02,  0x3B614AB8,  0x4C667A2E,
 	0xDCD967BF,  0xABDE5729,  0x32D70693,  0x45D03605,
drivers/net/wan/sbni.h +1 -1
index 8426451..7e6d980 100644
@@ -132,7 +132,7 @@ struct sbni_flags {
 /*
  * CRC-32 stuff
  */
-#define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00FFFFFF))
+#define CRC32(c,crc) (sbni_crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00FFFFFF))
       /* CRC generator 0xEDB88320 */
       /* CRC remainder 0x2144DF1C */
       /* CRC initial value 0x00000000 */
Signature · 1 line
1.8.3.1
maintainer
#17 lore raw

Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

From: Andi Kleen <[email protected]>
Date: Tue, 22 Oct 2013 09:12:26 -0700

Quoted 9 lines

From: Andi Kleen <[email protected]>

- Inline assembler defining C callable code has to be global
- The function has to be visible

Do this in wan/sbni

Is it really impossible to use the generic crc32 support instead of this unsightly custom inline assembler?

#18 lore raw

PATCH 1/1 net: wan: sbni: remove assembly crc32 code

There is also a C function doing the same thing. Unless the asm code is 110% faster we could stick to the C function.

---

Quoted 3 lines · David Miller

Is it really impossible to use the generic crc32 support instead of this unsightly custom inline assembler?

Since you asked for this here step 1.

 drivers/net/wan/sbni.c | 89 --------------------------------------------------
 1 file changed, 89 deletions(-)
drivers/net/wan/sbni.c +0 -89
index 5bbcb5e..388ddf6 100644
@@ -148,10 +148,6 @@ static int  enslave( struct net_device *, struct net_device * );
 static int  emancipate( struct net_device * );
 #endif
 
-#ifdef __i386__
-#define ASM_CRC 1
-#endif
-
 static const char  version[] =
 	"Granch SBNI12 driver ver 5.0.1  Jun 22 2001  Denis I.Timofeev.\n";
 
@@ -1551,88 +1547,6 @@ __setup( "sbni=", sbni_setup );
 
 /* -------------------------------------------------------------------------- */
 
-#ifdef ASM_CRC
-
-static u32
-calc_crc32( u32  crc,  u8  *p,  u32  len )
-{
-	register u32  _crc;
-	_crc = crc;
-	
-	__asm__ __volatile__ (
-		"xorl	%%ebx, %%ebx\n"
-		"movl	%2, %%esi\n" 
-		"movl	%3, %%ecx\n" 
-		"movl	$crc32tab, %%edi\n"
-		"shrl	$2, %%ecx\n"
-		"jz	1f\n"
-
-		".align 4\n"
-	"0:\n"
-		"movb	%%al, %%bl\n"
-		"movl	(%%esi), %%edx\n"
-		"shrl	$8, %%eax\n"
-		"xorb	%%dl, %%bl\n"
-		"shrl	$8, %%edx\n"
-		"xorl	(%%edi,%%ebx,4), %%eax\n"
-
-		"movb	%%al, %%bl\n"
-		"shrl	$8, %%eax\n"
-		"xorb	%%dl, %%bl\n"
-		"shrl	$8, %%edx\n"
-		"xorl	(%%edi,%%ebx,4), %%eax\n"
-
-		"movb	%%al, %%bl\n"
-		"shrl	$8, %%eax\n"
-		"xorb	%%dl, %%bl\n"
-		"movb	%%dh, %%dl\n" 
-		"xorl	(%%edi,%%ebx,4), %%eax\n"
-
-		"movb	%%al, %%bl\n"
-		"shrl	$8, %%eax\n"
-		"xorb	%%dl, %%bl\n"
-		"addl	$4, %%esi\n"
-		"xorl	(%%edi,%%ebx,4), %%eax\n"
-
-		"decl	%%ecx\n"
-		"jnz	0b\n"
-
-	"1:\n"
-		"movl	%3, %%ecx\n"
-		"andl	$3, %%ecx\n"
-		"jz	2f\n"
-
-		"movb	%%al, %%bl\n"
-		"shrl	$8, %%eax\n"
-		"xorb	(%%esi), %%bl\n"
-		"xorl	(%%edi,%%ebx,4), %%eax\n"
-
-		"decl	%%ecx\n"
-		"jz	2f\n"
-
-		"movb	%%al, %%bl\n"
-		"shrl	$8, %%eax\n"
-		"xorb	1(%%esi), %%bl\n"
-		"xorl	(%%edi,%%ebx,4), %%eax\n"
-
-		"decl	%%ecx\n"
-		"jz	2f\n"
-
-		"movb	%%al, %%bl\n"
-		"shrl	$8, %%eax\n"
-		"xorb	2(%%esi), %%bl\n"
-		"xorl	(%%edi,%%ebx,4), %%eax\n"
-	"2:\n"
-		: "=a" (_crc)
-		: "0" (_crc), "g" (p), "g" (len)
-		: "bx", "cx", "dx", "si", "di"
-	);
-
-	return  _crc;
-}
-
-#else	/* ASM_CRC */
-
 static u32
 calc_crc32( u32  crc,  u8  *p,  u32  len )
 {
@@ -1642,9 +1556,6 @@ calc_crc32( u32  crc,  u8  *p,  u32  len )
 	return  crc;
 }
 
-#endif	/* ASM_CRC */
-
-
 static u32  crc32tab[] __attribute__ ((aligned(8))) = {
 	0xD202EF8D,  0xA505DF1B,  0x3C0C8EA1,  0x4B0BBE37,
 	0xD56F2B94,  0xA2681B02,  0x3B614AB8,  0x4C667A2E,
Signature · 1 line
1.8.4.rc3
maintainer
#19 lore raw

Re: [PATCH] net: wan: sbni: remove assembly crc32 code

From: Sebastian Andrzej Siewior <[email protected]>
Date: Tue, 22 Oct 2013 20:36:25 +0200

Quoted 5 lines

There is also a C function doing the same thing. Unless the asm code is 110% faster we could stick to the C function.

Quoted 8 lines

---

Quoted 3 lines · David Miller

Is it really impossible to use the generic crc32 support instead of this unsightly custom inline assembler?

Since you asked for this here step 1.

If it's that simple, this is definitely what we should do.

On the off chance, is there anyone actually able to test this change? :-)))

author
#20 lore raw

Re: [PATCH] net: wan: sbni: remove assembly crc32 code

In reply to Sebastian Andrzej Siewior
Quoted 3 lines · Sebastian Andrzej Siewior

There is also a C function doing the same thing. Unless the asm code is 110% faster we could stick to the C function.

I have no idea if it is or not. But doing it this way would be acceptable for me.

Thanks for the patch.

-Andi

author
#22 lore raw

Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

In reply to David Miller
Quoted 8 lines · David Miller

From: Andi Kleen <[email protected]>
Date: Tue, 22 Oct 2013 09:12:26 -0700

Quoted 5 lines

From: Andi Kleen <[email protected]>

- Inline assembler defining C callable code has to be global
- The function has to be visible

Quoted 7 lines
Quoted 4 lines

Do this in wan/sbni

Is it really impossible to use the generic crc32 support instead of this unsightly custom inline assembler?

Yes it's impossible.

There's no way for me to test it, and this would be a far too big change to submit untested.

Also my only interest here is this thing not breaking my LTO allyesconfig build. I'm not even sure what it does.

Just because some legacy driver breaks my build you cannot make me accountable for maintaining it now.

If it's not possible to get this trivial change in I would need to mark it "depends on !LTO" in Kconfig.

-Andi

#23 lore raw

Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

2013/10/22 Andi Kleen <[email protected]>:

Quoted 22 lines · David Miller
Quoted 8 lines

From: Andi Kleen <[email protected]>
Date: Tue, 22 Oct 2013 09:12:26 -0700

Quoted 5 lines

From: Andi Kleen <[email protected]>

- Inline assembler defining C callable code has to be global
- The function has to be visible

Quoted 7 lines
Quoted 4 lines

Do this in wan/sbni

Is it really impossible to use the generic crc32 support instead of this unsightly custom inline assembler?

Yes it's impossible.

There's no way for me to test it, and this would be a far too big change to submit untested.

Quoted 8 lines

Also my only interest here is this thing not breaking my LTO allyesconfig build. I'm not even sure what it does.

Just because some legacy driver breaks my build you cannot make me accountable for maintaining it now.

If it's not possible to get this trivial change in I would need to mark it "depends on !LTO" in Kconfig.

How about scheduling the WAN drivers for removal? Does anybody actually use them nowadays?
--
Florian

author
#24 lore raw

Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

Quoted 2 lines

How about scheduling the WAN drivers for removal? Does anybody actually use them nowadays?

Perhaps at least the ISA devices? ISA hardware should be nearing end of live by now.

Looking at the git log there doesn't seem to be any real changes, other than tree sweeps or build fixes.

But I must admit I don't really know much about them.

-Andi

#25 lore raw

Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

In reply to Florian Fainelli

Florian Fainelli <[email protected]> :
[...]

Quoted 2 lines

How about scheduling the WAN drivers for removal? Does anybody actually use them nowadays?

There is still some interest in WAN drivers, see Christophe Leroy posting on 2013/10/13 "[PATCH] WAN: Adding support for Infineon PEF2256 E1 chipset" (buggy but it's a different topic).

Signature · 1 line
Ueimor