[OpenBIOS] Booting SunOS from OpenBIOS

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Wed Apr 3 00:01:52 CEST 2013

On 02/04/13 22:37, Artyom Tarasenko wrote:

>> Ah I think I may see the bug here - what if you change arch/sparc32/lib.c
>> line 276 in obp_memalloc() from:
>> virt = ofmem_claim_virt(pointer2cell(va), size, 0);
>> to:
>> virt = ofmem_claim_virt(pointer2cell(va), size, align);
>> Does that fix the bug for you?
> At least, it seems to die some instructions later, thanks! Will debug more.
> Does it mean that obp_memalloc is actually using the first argument
> just as a hint? As the OpenSolaris header suggests?

(goes away and tests)

Hmmmm I'm not sure that does the right thing as the change causes my 
Solaris 8 boot to crash. Basically if align is not set to zero then the 
virtual address is ignored, and OFMEM simply allocates a chunk of memory 
on the specified alignment. From my boot here with this change:

Breakpoint 1, obp_memalloc (va=0xf0040000 <Address 0xf0040000 out of 
bounds>, size=262144, align=262144) at 
273         phys = ofmem_claim_phys(-1, size, align);
(gdb) p/x align
$1 = 0x40000
(gdb) next
276         virt = ofmem_claim_virt(pointer2cell(va), size, align);
(gdb) p/x phys
$2 = 0x6f40000
(gdb) next
279         ofmem_map(phys, virt, size, 
(gdb) p/x virt
$3 = 0xffc40000
(gdb) next
281         return cell2pointer(virt);
(gdb) p/x virt
$4 = 0xffc40000
(gdb) next
282     }
0x001134e8 in ?? ()
(gdb) cont
Remote connection closed

So it would seem that the caller is definitely expecting to get a VA of 
0xf0040000 back. In fact looking at 
the caller only accepts the same VA being returned as an indication of 

This does remind me of a problem on SPARC64 where we get warnings from 
the bootloader because we are trying to reallocate the same region. 
Perhaps the right question to ask is what should the behaviour be if a 
region is allocated twice? For example, what should happen in this case 

virt1 = ofmem_claim(0xf0004000, 0x2000, 0);
virt2 = ofmem_claim(0xf0004000, 0x1000, 0);

If the virtual address 0xf0004000 is already claimed and mapped, should 
the old mapping be completely removed, or would we have to do something 
more complex such as split the mapped region into a new physical region 
and remap the first half of the split virtual region to the new physical 

Also for reference, can you post a tar.gz of your output with both 
CONFIG_DEBUG_OBP and CONFIG_DEBUG_OFMEM enabled for the build (but 
without my modification) so we can see the duplicate memalloc?



More information about the OpenBIOS mailing list