summaryrefslogtreecommitdiffstats
path: root/drivers/firmware/efi/libstub/intrinsics.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2022-10-11 15:15:51 +0200
committerArd Biesheuvel <ardb@kernel.org>2022-11-09 12:42:02 +0100
commit52dce39cd2786673969a12d1c94e0922d9208f83 (patch)
treeb05c22bae7499c7f1f61430ba296a900bbea75bc /drivers/firmware/efi/libstub/intrinsics.c
parentfa882a1389b2a6eaba8a0d5439dbd32537d0ecc5 (diff)
downloadlinux-stable-52dce39cd2786673969a12d1c94e0922d9208f83.tar.gz
linux-stable-52dce39cd2786673969a12d1c94e0922d9208f83.tar.bz2
linux-stable-52dce39cd2786673969a12d1c94e0922d9208f83.zip
efi: libstub: Clone memcmp() into the stub
We will no longer be able to call into the kernel image once we merge the decompressor with the EFI stub, so we need our own implementation of memcmp(). Let's add the one from lib/string.c and simplify it. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'drivers/firmware/efi/libstub/intrinsics.c')
-rw-r--r--drivers/firmware/efi/libstub/intrinsics.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/firmware/efi/libstub/intrinsics.c b/drivers/firmware/efi/libstub/intrinsics.c
index a04ab39292b6..965e734f6f98 100644
--- a/drivers/firmware/efi/libstub/intrinsics.c
+++ b/drivers/firmware/efi/libstub/intrinsics.c
@@ -28,3 +28,21 @@ void *memset(void *dst, int c, size_t len)
efi_bs_call(set_mem, dst, len, c & U8_MAX);
return dst;
}
+
+/**
+ * memcmp - Compare two areas of memory
+ * @cs: One area of memory
+ * @ct: Another area of memory
+ * @count: The size of the area.
+ */
+#undef memcmp
+int memcmp(const void *cs, const void *ct, size_t count)
+{
+ const unsigned char *su1, *su2;
+ int res = 0;
+
+ for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
+ if ((res = *su1 - *su2) != 0)
+ break;
+ return res;
+}