FDT: alignment of 64-bits integers
Hi Simon,
while working with the FDT in the SPL, I came across an alignment issue. I have seen 64-bits integers not aligned on a 64-bit boundary, although is doesn't happen very often. According to the FDT spec, the requirement is to be aligned on 32-bits, so it is OK.
However on ARM64, until the cache is enabled, it is not possible to access 64-bits integers not aligned on a 64-bits boundary. This issue has been discussed here :
http://u-boot.10912.n7.nabble.com/memcpy-memset-on-arm64-platforms-td353928.html#a354348
I have a patch for this but I am not sure, this is the right approach:
include/linux/libfdt_env.h +1 -1
@@ -15,7 +15,7 @@ typedef __be16 fdt16_t; typedef __be32 fdt32_t; -typedef __be64 fdt64_t ; +typedef __be64 fdt64_t __aligned(4) ;
The trouble with this patch is that for every fdt64_t the access will be aligned on 32-bits, inducing an overall performance penalty.
The other approach will be to fix the problem where it happens. So far
I had the issue only ofnode_read_u64() because that is what the driver I worked with is using.
What do you think?
Thanks,
JJ
Hi Jean-Jacques,
Quoted 29 lines · Jean-Jacques Hiblot
Hi Simon,
while working with the FDT in the SPL, I came across an alignment issue. I have seen 64-bits integers not aligned on a 64-bit boundary, although is doesn't happen very often. According to the FDT spec, the requirement is to be aligned on 32-bits, so it is OK.
However on ARM64, until the cache is enabled, it is not possible to access 64-bits integers not aligned on a 64-bits boundary. This issue has been discussed here :
http://u-boot.10912.n7.nabble.com/memcpy-memset-on-arm64-platforms-td353928.html#a354348I have a patch for this but I am not sure, this is the right approach:
include/linux/libfdt_env.h +1
-1@@ -15,7 +15,7 @@typedef __be16 fdt16_t ;typedef __be32 fdt32_t ; -typedef __be64 fdt64_t ; +typedef __be64 fdt64_t __aligned(4) ;The trouble with this patch is that for every
fdt64_tthe access will be aligned on 32-bits, inducing an overall performance penalty.
Quoted 5 lines
The other approach will be to fix the problem where it happens. So far
I had the issue onlyofnode_read_u64()because that is what the driver I worked with is using.What do you think?
Probably if you can fix it in the ofnode function that would be more efficient.
For some reason this shows up with a 'corrupt patch' error when I try to apply it.
Regards,
Simon