[coreboot-gerrit] Change in coreboot[master]: cbmem: Add custom aligned memcpy() implementation

Julius Werner (Code Review) gerrit at coreboot.org
Tue Apr 11 00:53:08 CEST 2017


Julius Werner has posted comments on this change. ( https://review.coreboot.org/18300 )

Change subject: cbmem: Add custom aligned memcpy() implementation
......................................................................


Patch Set 1:

(2 comments)

> While I like the idea don't you bite your own tail by doing unaligned transfers using u8 first?

Not really sure what you mean here. As I mentioned in the discussion with Aaron, I'm assuming that a naturally aligned access is always okay (which I'm pretty sure is true across essentially all relevant architectures today, at least the ones coreboot runs on). A byte-sized access is always naturally aligned, so that's why I'm using those until the pointer is machine-word-aligned again.

https://review.coreboot.org/#/c/18300/1/util/cbmem/cbmem.c
File util/cbmem/cbmem.c:

PS1, Line 66: never do unaligned accesses
> how about assert(src % sizeof(size_t)) then, and removing the first loop? (
Uhh... what? Then this code will crash (with "assertion failed") when I try to copy an unaligned section out, which is not what I want. I can already have that before this patch (just with a SIGBUS instead). What I want is a memcpy function that can transparently detect and deal with that case, which is what my code does (by reading out the memory byte-by-byte until the pointer is aligned again, then proceeding with normal (faster) word-sized reads.


PS1, Line 77: *d++ = *s++;
> Maybe leave a comment saying the compiler may optimize this back into a mem
Added comment.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I03eece380a14a69d4be3805ed72fba640f6f7d9c
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Julius Werner <jwerner at chromium.org>
Gerrit-Reviewer: Aaron Durbin <adurbin at chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan at google.com>
Gerrit-Reviewer: Julius Werner <jwerner at chromium.org>
Gerrit-Reviewer: Patrick Georgi <pgeorgi at google.com>
Gerrit-Reviewer: Patrick Rudolph <siro at das-labor.org>
Gerrit-Reviewer: Paul Menzel <paulepanter at users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins)
Gerrit-HasComments: Yes



More information about the coreboot-gerrit mailing list