[coreboot-gerrit] Change in coreboot[master]: libpayload: memset should support unaligned pointer

Jérémy Compostella (Code Review) gerrit at coreboot.org
Tue Jul 11 02:29:09 CEST 2017


Jérémy Compostella has uploaded this change for review. ( https://review.coreboot.org/20524


Change subject: libpayload: memset should support unaligned pointer
......................................................................

libpayload: memset should support unaligned pointer

The optimization of the memset() function introduced by commit
dbadb1dd634c8c9419215ade0666a7fb69a4447b is provoking an issue on x86
platform when compile without the CONFIG_GPL option.

GCC is making use of the movdqa instruction to copy words.  This
instruction can raise a "General Protection Fault Exception" when it
is called on a non-aligned address argument.

Change-Id: I73382a76a4399d8e78244867f2ebb1dca176a6bf
Signed-off-by: Jeremy Compostella <jeremy.compostella at intel.com>
---
M payloads/libpayload/libc/memory.c
1 file changed, 5 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/20524/1

diff --git a/payloads/libpayload/libc/memory.c b/payloads/libpayload/libc/memory.c
index ae476cf..cb56802 100644
--- a/payloads/libpayload/libc/memory.c
+++ b/payloads/libpayload/libc/memory.c
@@ -38,6 +38,11 @@
 	size_t i;
 	void *ret = s;
 	unsigned long w = c & 0xff;
+	u8 *p = (u8 *)s;
+
+	s = (void *)ALIGN_UP((unsigned long)s, sizeof(unsigned long));
+	while (p < s && n--)
+		*p++ = c;
 
 	for (i = 1; i < sizeof(unsigned long); i <<= 1)
 		w = (w << (i * 8)) | w;

-- 
To view, visit https://review.coreboot.org/20524
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I73382a76a4399d8e78244867f2ebb1dca176a6bf
Gerrit-Change-Number: 20524
Gerrit-PatchSet: 1
Gerrit-Owner: Jérémy Compostella <jeremy.compostella at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170711/6bdb4756/attachment-0001.html>


More information about the coreboot-gerrit mailing list