提交 5a9f480a 编写于 作者: G Gaosheng Cui 提交者: Zheng Zengkai

efi/libstub: arm64: support strchr function for EFI stub

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5J0X7
CVE: NA

--------------------------------

Since arm64 does not use a builtin decompressor, the EFI stub is built
into the kernel proper. 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.

Follow the rules and support strchr function for EFI stub, it will be
used to parse cmdline args.
Signed-off-by: NGaosheng Cui <cuigaosheng1@huawei.com>
Reviewed-by: NWang Weiyang <wangweiyang2@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 6d9aaec1
......@@ -35,6 +35,7 @@ __efistub_strnlen = __pi_strnlen;
__efistub_strcmp = __pi_strcmp;
__efistub_strncmp = __pi_strncmp;
__efistub_strrchr = __pi_strrchr;
__efistub_strchr = __pi_strchr;
__efistub___clean_dcache_area_poc = __pi___clean_dcache_area_poc;
#ifdef CONFIG_KASAN
......
......@@ -18,7 +18,7 @@
* Returns:
* x0 - address of first occurrence of 'c' or 0
*/
SYM_FUNC_START_WEAK(strchr)
SYM_FUNC_START_WEAK_PI(strchr)
and w1, w1, #0xff
1: ldrb w2, [x0], #1
cmp w2, w1
......@@ -28,5 +28,5 @@ SYM_FUNC_START_WEAK(strchr)
cmp w2, w1
csel x0, x0, xzr, eq
ret
SYM_FUNC_END(strchr)
SYM_FUNC_END_PI(strchr)
EXPORT_SYMBOL_NOKASAN(strchr)
......@@ -113,3 +113,21 @@ long simple_strtol(const char *cp, char **endp, unsigned int base)
return simple_strtoull(cp, endp, base);
}
#ifndef __HAVE_ARCH_STRCHR
/**
* strchr - Find the first occurrence of a character in a string
* @s: The string to be searched
* @c: The character to search for
*
* Note that the %NUL-terminator is considered part of the string, and can
* be searched for.
*/
char *strchr(const char *s, int c)
{
for (; *s != (char)c; ++s)
if (*s == '\0')
return NULL;
return (char *)s;
}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册