Author: mcayland Date: Sun Feb 16 17:26:43 2014 New Revision: 1268 URL: http://tracker.coreboot.org/trac/openbios/changeset/1268
Log: OFMEM: ensure minimum alignment of PAGE_SIZE
NextStep appears to request an alignment of 4 for some of its large memory ranges, and since this is an exact power of 2 then the code to ensure a minimum alignment of PAGE_SIZE is accidentally bypassed. Move this to a separate check so we can guarantee the minimum alignment requirement is always observed.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c ============================================================================== --- trunk/openbios-devel/libopenbios/ofmem_common.c Sun Feb 16 17:26:40 2014 (r1267) +++ trunk/openbios-devel/libopenbios/ofmem_common.c Sun Feb 16 17:26:43 2014 (r1268) @@ -428,13 +428,20 @@ { phys_addr_t base = min; range_t *r2; - ucell old_align; + ucell old_align = align; int i;
+ if( (align < PAGE_SIZE) ) { + + /* Minimum alignment is page size */ + align = PAGE_SIZE; + + OFMEM_TRACE("warning: bad alignment " FMT_ucellx " rounded up to " FMT_ucellx "\n", old_align, align); + } + if( (align & (align-1)) ) { /* As per IEEE1275 specification, round up to the nearest power of 2 */ - old_align = align; if (old_align <= PAGE_SIZE) { align = PAGE_SIZE; } else { @@ -447,8 +454,6 @@ OFMEM_TRACE("warning: bad alignment " FMT_ucellx " rounded up to " FMT_ucellx "\n", old_align, align); } - if( !align ) - align = PAGE_SIZE;
base = reverse ? max - size : min; r2 = reverse ? NULL : r;