Skip to content

Commit db1a8b9

Browse files
committed
tools arch: Update arch/x86/lib/mem{cpy,set}_64.S copies used in 'perf bench mem memcpy'
To bring in the change made in this cset: 4d6ffa2 ("x86/lib: Change .weak to SYM_FUNC_START_WEAK for arch/x86/lib/mem*_64.S") 6dcc562 ("x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_*") I needed to define SYM_FUNC_START_LOCAL() as SYM_L_GLOBAL as mem{cpy,set}_{orig,erms} are used by 'perf bench'. This silences these perf tools build warnings: Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs from latest version at 'arch/x86/lib/memcpy_64.S' diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S Warning: Kernel ABI header at 'tools/arch/x86/lib/memset_64.S' differs from latest version at 'arch/x86/lib/memset_64.S' diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: Fangrui Song <maskray@google.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Jiri Slaby <jirislaby@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent b0e5a05 commit db1a8b9

5 files changed

Lines changed: 22 additions & 10 deletions

File tree

‎tools/arch/x86/lib/memcpy_64.S‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* to a jmp to memcpy_erms which does the REP; MOVSB mem copy.
1717
*/
1818

19-
.weak memcpy
20-
2119
/*
2220
* memcpy - Copy a memory block.
2321
*
@@ -30,7 +28,7 @@
3028
* rax original destination
3129
*/
3230
SYM_FUNC_START_ALIAS(__memcpy)
33-
SYM_FUNC_START_LOCAL(memcpy)
31+
SYM_FUNC_START_WEAK(memcpy)
3432
ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
3533
"jmp memcpy_erms", X86_FEATURE_ERMS
3634

@@ -51,14 +49,14 @@ EXPORT_SYMBOL(__memcpy)
5149
* memcpy_erms() - enhanced fast string memcpy. This is faster and
5250
* simpler than memcpy. Use memcpy_erms when possible.
5351
*/
54-
SYM_FUNC_START(memcpy_erms)
52+
SYM_FUNC_START_LOCAL(memcpy_erms)
5553
movq %rdi, %rax
5654
movq %rdx, %rcx
5755
rep movsb
5856
ret
5957
SYM_FUNC_END(memcpy_erms)
6058

61-
SYM_FUNC_START(memcpy_orig)
59+
SYM_FUNC_START_LOCAL(memcpy_orig)
6260
movq %rdi, %rax
6361

6462
cmpq $0x20, %rdx

‎tools/arch/x86/lib/memset_64.S‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
#include <linux/linkage.h>
55
#include <asm/cpufeatures.h>
66
#include <asm/alternative-asm.h>
7-
8-
.weak memset
7+
#include <asm/export.h>
98

109
/*
1110
* ISO C memset - set a memory block to a byte value. This function uses fast
@@ -18,7 +17,7 @@
1817
*
1918
* rax original destination
2019
*/
21-
SYM_FUNC_START_ALIAS(memset)
20+
SYM_FUNC_START_WEAK(memset)
2221
SYM_FUNC_START(__memset)
2322
/*
2423
* Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
@@ -44,6 +43,8 @@ SYM_FUNC_START(__memset)
4443
ret
4544
SYM_FUNC_END(__memset)
4645
SYM_FUNC_END_ALIAS(memset)
46+
EXPORT_SYMBOL(memset)
47+
EXPORT_SYMBOL(__memset)
4748

4849
/*
4950
* ISO C memset - set a memory block to a byte value. This function uses
@@ -56,7 +57,7 @@ SYM_FUNC_END_ALIAS(memset)
5657
*
5758
* rax original destination
5859
*/
59-
SYM_FUNC_START(memset_erms)
60+
SYM_FUNC_START_LOCAL(memset_erms)
6061
movq %rdi,%r9
6162
movb %sil,%al
6263
movq %rdx,%rcx
@@ -65,7 +66,7 @@ SYM_FUNC_START(memset_erms)
6566
ret
6667
SYM_FUNC_END(memset_erms)
6768

68-
SYM_FUNC_START(memset_orig)
69+
SYM_FUNC_START_LOCAL(memset_orig)
6970
movq %rdi,%r10
7071

7172
/* expand byte value */

‎tools/perf/bench/mem-memcpy-x86-64-asm.S‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
/* Various wrappers to make the kernel .S file build in user-space: */
44

5+
// memcpy_orig and memcpy_erms are being defined as SYM_L_LOCAL but we need it
6+
#define SYM_FUNC_START_LOCAL(name) \
7+
SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
58
#define memcpy MEMCPY /* don't hide glibc's memcpy() */
69
#define altinstr_replacement text
710
#define globl p2align 4; .globl

‎tools/perf/bench/mem-memset-x86-64-asm.S‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2+
// memset_orig and memset_erms are being defined as SYM_L_LOCAL but we need it
3+
#define SYM_FUNC_START_LOCAL(name) \
4+
SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
25
#define memset MEMSET /* don't hide glibc's memset() */
36
#define altinstr_replacement text
47
#define globl p2align 4; .globl

‎tools/perf/util/include/linux/linkage.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
/* SYM_L_* -- linkage of symbols */
2727
#define SYM_L_GLOBAL(name) .globl name
28+
#define SYM_L_WEAK(name) .weak name
2829
#define SYM_L_LOCAL(name) /* nothing */
2930

3031
#define ALIGN __ALIGN
@@ -84,6 +85,12 @@
8485
SYM_END(name, SYM_T_FUNC)
8586
#endif
8687

88+
/* SYM_FUNC_START_WEAK -- use for weak functions */
89+
#ifndef SYM_FUNC_START_WEAK
90+
#define SYM_FUNC_START_WEAK(name) \
91+
SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN)
92+
#endif
93+
8794
/*
8895
* SYM_FUNC_END -- the end of SYM_FUNC_START_LOCAL, SYM_FUNC_START,
8996
* SYM_FUNC_START_WEAK, ...

0 commit comments

Comments
 (0)