Author: mcayland Date: Thu Dec 30 23:02:09 2010 New Revision: 997 URL: http://tracker.coreboot.org/trac/openbios/changeset/997
Log: Fix ofmem_posix_memalign() so that it also enforces physical alignment when re-allocating memory from the freelist.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.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 Thu Dec 30 14:56:28 2010 (r996) +++ trunk/openbios-devel/libopenbios/ofmem_common.c Thu Dec 30 23:02:09 2010 (r997) @@ -108,7 +108,11 @@
/* waste at most 4K by taking an entry from the freelist */ if( *pp && (**pp).size < size + 0x1000 ) { - ret = (void *)((uintptr_t)*pp + sizeof(alloc_desc_t)); + /* Alignment should be on physical not virtual address */ + pa = va2pa((uintptr_t)*pp + sizeof(alloc_desc_t)); + pa = align_ptr(pa, alignment); + ret = (void *)pa2va(pa); + memset( ret, 0, (**pp).size - sizeof(alloc_desc_t) ); *pp = (**pp).next;