diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2015-10-08 15:02:04 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2015-10-12 11:20:12 -0400 |
commit | e8f3010f7326c00368dbc057bd052bec80dfc072 (patch) | |
tree | 111ad1d750410588ecd346fc257c05565963f0fd /drivers/firmware/efi/libstub/string.c | |
parent | 207918461eb0aca720fddec5da79bc71c133b9f1 (diff) |
arm64/efi: isolate EFI stub from the kernel proper
Since arm64 does not use a builtin decompressor, the EFI stub is built
into the kernel proper. So far, this has been working fine, but actually,
since the stub is in fact a PE/COFF relocatable binary that is executed
at an unknown offset in the 1:1 mapping provided by the UEFI firmware, we
should not be seamlessly sharing code with the kernel proper, which is a
position dependent executable linked at a high virtual offset.
So instead, separate the contents of libstub and its dependencies, by
putting them into their own namespace by prefixing all of its symbols
with __efistub. This way, we have tight control over what parts of the
kernel proper are referenced by the stub.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'drivers/firmware/efi/libstub/string.c')
-rw-r--r-- | drivers/firmware/efi/libstub/string.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/firmware/efi/libstub/string.c b/drivers/firmware/efi/libstub/string.c new file mode 100644 index 000000000000..09d5a0894343 --- /dev/null +++ b/drivers/firmware/efi/libstub/string.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | * Taken from: | ||
3 | * linux/lib/string.c | ||
4 | * | ||
5 | * Copyright (C) 1991, 1992 Linus Torvalds | ||
6 | */ | ||
7 | |||
8 | #include <linux/types.h> | ||
9 | #include <linux/string.h> | ||
10 | |||
11 | #ifndef __HAVE_ARCH_STRSTR | ||
12 | /** | ||
13 | * strstr - Find the first substring in a %NUL terminated string | ||
14 | * @s1: The string to be searched | ||
15 | * @s2: The string to search for | ||
16 | */ | ||
17 | char *strstr(const char *s1, const char *s2) | ||
18 | { | ||
19 | size_t l1, l2; | ||
20 | |||
21 | l2 = strlen(s2); | ||
22 | if (!l2) | ||
23 | return (char *)s1; | ||
24 | l1 = strlen(s1); | ||
25 | while (l1 >= l2) { | ||
26 | l1--; | ||
27 | if (!memcmp(s1, s2, l2)) | ||
28 | return (char *)s1; | ||
29 | s1++; | ||
30 | } | ||
31 | return NULL; | ||
32 | } | ||
33 | #endif | ||
34 | |||
35 | #ifndef __HAVE_ARCH_STRNCMP | ||
36 | /** | ||
37 | * strncmp - Compare two length-limited strings | ||
38 | * @cs: One string | ||
39 | * @ct: Another string | ||
40 | * @count: The maximum number of bytes to compare | ||
41 | */ | ||
42 | int strncmp(const char *cs, const char *ct, size_t count) | ||
43 | { | ||
44 | unsigned char c1, c2; | ||
45 | |||
46 | while (count) { | ||
47 | c1 = *cs++; | ||
48 | c2 = *ct++; | ||
49 | if (c1 != c2) | ||
50 | return c1 < c2 ? -1 : 1; | ||
51 | if (!c1) | ||
52 | break; | ||
53 | count--; | ||
54 | } | ||
55 | return 0; | ||
56 | } | ||
57 | #endif | ||