mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 02:15:45 +01:00 
			
		
		
		
	fdt: Fix alignment issue when reading 64-bits properties from fdt
The FDT specification [0] gives a requirement of aligning properties on 32-bits. Make sure that the compiler is aware of this constraint when accessing 64-bits properties. [0]: https://github.com/devicetree-org/devicetree-specification/blob/master/source/flattened-format.rst Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
				
					committed by
					
						 Simon Glass
						Simon Glass
					
				
			
			
				
	
			
			
			
						parent
						
							97b5f9d1a0
						
					
				
				
					commit
					d60ae4c59d
				
			| @@ -1566,7 +1566,7 @@ static int fdt_read_prop(const fdt32_t *prop, int prop_len, int cell_off, | |||||||
| 			 uint64_t *val, int cells) | 			 uint64_t *val, int cells) | ||||||
| { | { | ||||||
| 	const fdt32_t *prop32 = &prop[cell_off]; | 	const fdt32_t *prop32 = &prop[cell_off]; | ||||||
| 	const fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off]; | 	const unaligned_fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off]; | ||||||
|  |  | ||||||
| 	if ((cell_off + cells) > prop_len) | 	if ((cell_off + cells) > prop_len) | ||||||
| 		return -FDT_ERR_NOSPACE; | 		return -FDT_ERR_NOSPACE; | ||||||
|   | |||||||
| @@ -57,7 +57,7 @@ int ofnode_read_s32_default(ofnode node, const char *propname, s32 def) | |||||||
|  |  | ||||||
| int ofnode_read_u64(ofnode node, const char *propname, u64 *outp) | int ofnode_read_u64(ofnode node, const char *propname, u64 *outp) | ||||||
| { | { | ||||||
| 	const fdt64_t *cell; | 	const unaligned_fdt64_t *cell; | ||||||
| 	int len; | 	int len; | ||||||
|  |  | ||||||
| 	assert(ofnode_valid(node)); | 	assert(ofnode_valid(node)); | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ | |||||||
| typedef __be16 fdt16_t; | typedef __be16 fdt16_t; | ||||||
| typedef __be32 fdt32_t; | typedef __be32 fdt32_t; | ||||||
| typedef __be64 fdt64_t; | typedef __be64 fdt64_t; | ||||||
|  | typedef __be64 unaligned_fdt64_t __aligned(4); | ||||||
|  |  | ||||||
| #define fdt32_to_cpu(x) be32_to_cpu(x) | #define fdt32_to_cpu(x) be32_to_cpu(x) | ||||||
| #define cpu_to_fdt32(x) cpu_to_be32(x) | #define cpu_to_fdt32(x) cpu_to_be32(x) | ||||||
|   | |||||||
| @@ -242,7 +242,7 @@ int fdtdec_get_pci_bar32(struct udevice *dev, struct fdt_pci_addr *addr, | |||||||
| uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name, | uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name, | ||||||
| 			   uint64_t default_val) | 			   uint64_t default_val) | ||||||
| { | { | ||||||
| 	const uint64_t *cell64; | 	const unaligned_fdt64_t *cell64; | ||||||
| 	int length; | 	int length; | ||||||
|  |  | ||||||
| 	cell64 = fdt_getprop(blob, node, prop_name, &length); | 	cell64 = fdt_getprop(blob, node, prop_name, &length); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user