Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Unaligned access in kernel on ARMv6+ (Re: CVS commit: src/sys/dev/usb)



On 06/01/2019 08:46, Rin Okuyama wrote:
(CC added to port-arm%NetBSD.org@localhost)

Let me summarize the problem briefly. In axe(4), there is a code where
memcpy() is carried out from 2-byte aligned buffer to 4-byte structure:

https://nxr.netbsd.org/xref/src/sys/dev/usb/if_axe.c#1284

This results in kernel panic due to alignment fault on earmv[67]hf:

https://twitter.com/furandon_pig/status/1071771151418908672

In short, this is because -munaligned-access is enabled on ARMv6+ by
default for GCC. As the unaligned memory access is forbidden in the
supervisor mode unlike in the user mode, we need to explicitly specify
-mno-unaligned-access for kernel on ARMv6+.


I'm pretty sure this is the same as http://gnats.netbsd.org/50038

Maybe I should be brave enough to stop using PMAP_NOCACHE in bus_dma.c for armv6+ and fix any missing bus_dmamap_sync calls.

Nick



Home | Main Index | Thread Index | Old Index