<div dir="ltr">bummer. We're going to have to add marshalling code to cbfs, to copy pointers from the architecture we're on to the architecture we're on, which was compiled by gcc for the architecture we're on, compiled on the architecture we're not on, to conform to rules for an architecture we're not on.<div><br></div><div>goodbye, a = b</div><div>hello, memcpy(&a, &b, sizeof(a));</div><div>barf.</div><div><br></div><div>ron</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 17, 2015 at 1:23 PM Aaron Durbin <<a href="mailto:adurbin@google.com">adurbin@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Jul 17, 2015 at 2:45 PM, ron minnich <<a href="mailto:rminnich@gmail.com" target="_blank">rminnich@gmail.com</a>> wrote:<br>
> riscv is taking alignment traps reading cbfs.<br>
><br>
> The issue is that 64-bit fields are 32-bit aligned, which fails many places.<br>
><br>
> Thaminda found this comment:<br>
><br>
>   * Since coreboot is usually compiled 32bit, gcc will align 64bit<br>
>  * types to 32bit boundaries. If the coreboot table is dumped on a<br>
>  * 64bit system, a uint64_t would be aligned to 64bit boundaries,<br>
>  * breaking the table format.<br>
><br>
> this is a real problem. Would have broken badly on Alpha, and breaks badly<br>
> on RISCV.<br>
><br>
> We can fix it, with an ugly macro, but ... what's the right move here?<br>
<br>
You mean how none of the structs in src/include/boot/coreboot_tables.h<br>
have a packed attribute decorated on them? And they should be marked<br>
packed since these are a serialized format. That's not really going to<br>
help you.<br>
<br>
One thing you do is break up all uint64_t in that header to be a<br>
struct of 2 uint32_t -- which is what lb_uint64 was for I assume. What<br>
that means is the types all need to be marshalled properly, and you'd<br>
have to do this as it is if RISC V doesn't support unaligned accesses.<br>
<br>
In general, coreboot has been largely written to assume unaligned<br>
accesses are no big deal (thanks, x86!). Because of this architectures<br>
like ARM *have* to get their MMUs up to enable normal memory so that<br>
it can honor the "handle unaligned accesses".<br>
<br>
><br>
> ron<br>
><br>
> --<br>
> coreboot mailing list: <a href="mailto:coreboot@coreboot.org" target="_blank">coreboot@coreboot.org</a><br>
> <a href="http://www.coreboot.org/mailman/listinfo/coreboot" rel="noreferrer" target="_blank">http://www.coreboot.org/mailman/listinfo/coreboot</a><br>
</blockquote></div>