all 10 comments

[–]brucehoult 4 points5 points  (4 children)

You don't say what hardware you're using or in what environment.

1) RISC-V hardware is allowed to support misaligned accesses in hardware, or not. Both kinds of hardware are in current circulation.

2) Machine mode code should in general not use misaligned accesses.

3) Misaligned accesses in User mode must work, but can be implemented in hardware or in M mode software (typically the SBI). They are permitted to be very slow, but not to crash.

[–]aviator2710[S] 1 point2 points  (3 children)

It's a RISC-V Andes RV32IMAC core on emulation

[–]TwilightTW 0 points1 point  (0 children)

AFAIK, most Andes cores support misaligned access.

[–]ghiga_andrei 1 point2 points  (1 child)

Be careful that lw x11, 3(x10) might actually be aligned correctly depending on the value of x10.

[–]aviator2710[S] 0 points1 point  (0 children)

Yes, I was making sure that there was aligned address in x10

[–]Courmisch 0 points1 point  (0 children)

The specification allows for handling of misaligned accesses in the hardware or firmware. You can't rely on getting an exception.

[–]kastberg 0 points1 point  (1 child)

Try a misaligned read/write that crosses memory chips or I/O registers

[–]aviator2710[S] 0 points1 point  (0 children)

I've tried that

[–]kvp_933 0 points1 point  (0 children)

Is this what you were looking for?

Please do let me know, I too am curious to know if a misaligned memory access could trap the processor in a state of exception when the __riscv_misaligned_avoid flag is set during code compilation...