UPSTREAM: commonlib/lz4: Avoid unaligned memory access on RISC-V
From the User-Level ISA Specification v2.0:
"We do not mandate atomicity for misaligned accesses so simple
implementations can just use a machine trap and software handler to
handle misaligned accesses." ( http://riscv.org/specifications/)
Spike traps on unaligned accesses.
Change-Id: Ia57786916f4076cc08513f4e331c2deec9cfa785
Original-Signed-off-by: Jonathan Neuschfer <j.neuschaefer@gmx.net>
Original-Reviewed-on: https://review.coreboot.org/14983
Original-Tested-by: build bot (Jenkins)
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
(cherry-picked from commit 4acb0e7742)
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/348411
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
parent
f68f132f10
commit
a87feb061b
1 changed files with 5 additions and 0 deletions
|
|
@ -63,6 +63,11 @@ static void LZ4_copy8(void *dst, const void *src)
|
|||
: [src]"r"(src), [dst]"r"(dst)
|
||||
: "memory" );
|
||||
#endif
|
||||
#elif defined(__riscv__)
|
||||
/* RISC-V implementations may trap on any unaligned access. */
|
||||
int i;
|
||||
for (i = 0; i < 8; i++)
|
||||
((uint8_t *)dst)[i] = ((uint8_t *)src)[i];
|
||||
#else
|
||||
*(uint64_t *)dst = *(const uint64_t *)src;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue