-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'x86/boot' of git://git.kernel.org/pub/scm/linux/kernel/…
…git/tip/tip Pull x86 boot changes from Peter Anvin: "This patchset is a set of cleanups aiming at librarize some of the common code from the boot environments. We currently have three different "little environments" (boot, boot/compressed, and realmode/rm) in x86, and we are likely to soon get a fourth one (kexec/purgatory, which will have to be integrated in the kernel to support secure kexec). This is primarily a cleanup in the anticipation of the latter. While Vivek implemented this, he ran into some bugs, in particular the memcmp implementation for when gcc punts from using the builtin would have a misnamed symbol, causing compilation errors if we were ever unlucky enough that gcc didn't want to inline the test" * 'x86/boot' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86, boot: Move memset() definition in compressed/string.c x86, boot: Move memcmp() into string.h and string.c x86, boot: Move optimized memcpy() 32/64 bit versions to compressed/string.c x86, boot: Create a separate string.h file to provide standard string functions x86, boot: Undef memcmp before providing a new definition
- Loading branch information
Showing
10 changed files
with
88 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,45 @@ | ||
#include "misc.h" | ||
#include "../string.c" | ||
|
||
/* misc.h might pull in string_32.h which has a macro for memcpy. undef that */ | ||
#undef memcpy | ||
|
||
int memcmp(const void *s1, const void *s2, size_t len) | ||
#ifdef CONFIG_X86_32 | ||
void *memcpy(void *dest, const void *src, size_t n) | ||
{ | ||
u8 diff; | ||
asm("repe; cmpsb; setnz %0" | ||
: "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len)); | ||
return diff; | ||
int d0, d1, d2; | ||
asm volatile( | ||
"rep ; movsl\n\t" | ||
"movl %4,%%ecx\n\t" | ||
"rep ; movsb\n\t" | ||
: "=&c" (d0), "=&D" (d1), "=&S" (d2) | ||
: "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src) | ||
: "memory"); | ||
|
||
return dest; | ||
} | ||
#else | ||
void *memcpy(void *dest, const void *src, size_t n) | ||
{ | ||
long d0, d1, d2; | ||
asm volatile( | ||
"rep ; movsq\n\t" | ||
"movq %4,%%rcx\n\t" | ||
"rep ; movsb\n\t" | ||
: "=&c" (d0), "=&D" (d1), "=&S" (d2) | ||
: "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src) | ||
: "memory"); | ||
|
||
#include "../string.c" | ||
return dest; | ||
} | ||
#endif | ||
|
||
void *memset(void *s, int c, size_t n) | ||
{ | ||
int i; | ||
char *ss = s; | ||
|
||
for (i = 0; i < n; i++) | ||
ss[i] = c; | ||
return s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
*/ | ||
|
||
#include "boot.h" | ||
#include "string.h" | ||
|
||
void initregs(struct biosregs *reg) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef BOOT_STRING_H | ||
#define BOOT_STRING_H | ||
|
||
/* Undef any of these macros coming from string_32.h. */ | ||
#undef memcpy | ||
#undef memset | ||
#undef memcmp | ||
|
||
void *memcpy(void *dst, const void *src, size_t len); | ||
void *memset(void *dst, int c, size_t len); | ||
int memcmp(const void *s1, const void *s2, size_t len); | ||
|
||
/* | ||
* Access builtin version by default. If one needs to use optimized version, | ||
* do "undef memcpy" in .c file and link against right string.c | ||
*/ | ||
#define memcpy(d,s,l) __builtin_memcpy(d,s,l) | ||
#define memset(d,c,l) __builtin_memset(d,c,l) | ||
#define memcmp __builtin_memcmp | ||
|
||
#endif /* BOOT_STRING_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters