<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Feb 1, 2019, 11:38 AM Hesham Almatary <<a href="mailto:hesham.almatary@cl.cam.ac.uk">hesham.almatary@cl.cam.ac.uk</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, 1 Feb 2019 at 15:08, Jiri Gaisler <<a href="mailto:jiri@gaisler.se" target="_blank" rel="noreferrer">jiri@gaisler.se</a>> wrote:<br>
><br>
> Hello,<br>
><br>
> As far as I understand, RISC-V does not require any particular alignment<br>
> of data structures in memory. Nevertheless, the compiler automatically<br>
> aligns data structures on their natural sizes, i.e. ints are aligned on<br>
> 4-byte and doubles on 8-bytes boundaries. sis-riscv with support for<br>
> doubles (extension D) checks that load and store double are properly<br>
> aligned on 8-byte boundaries. This works fine for all compiler-generated<br>
> code, (e.g. paranoia) but fails for spcontext01, where the context save<br>
> function in riscv-exception-handler.S tries to save 64-bit floating<br>
> point registers on a non-aligned stack address.<br>
><br>
> Is this an oversight in the code, or does the hardware (and simulators)<br>
> have to support unaligned accesses?<br>
><br>
Spike can be built to support either aligned or unaligned accesses. This<br>
includes floating points and integers. It's not in the spec that a RISC-V<br>
implementation has to support it or not (it's up to the platform),<br>
but if it doesn't, it should trigger an unaligned access trap and<br>
should be handled.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Then we should ensure proper alignment since we NEVER want an unaligned exception on any architecture if it is avoidable. No point in taking the likely performance hit or exception. </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
That said, I am not sure whether the intention of the RISC-V FPU<br>
implementation in RTEMS is assuming everything will be aligned<br>
(in which case some alignment checks should be added) or not.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">The intention is to avoid unaligned exceptions so this has to be accounted for.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I had another a look at the RISC-V Context_Control struct. I assume this only<br>
happens on rv32 with D extension?<br>
<br>
> Jiri.<br>
><br>
> _______________________________________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div></div>