[OpenBIOS] [commit] r1034 - trunk/openbios-devel/arch/sparc32

repository service svn at openbios.org
Fri Apr 8 11:04:00 CEST 2011


Author: mcayland
Date: Fri Apr  8 11:03:59 2011
New Revision: 1034
URL: http://tracker.coreboot.org/trac/openbios/changeset/1034

Log:
Enforce physical alignment based upon size for the SPARC32 romvec obp_dumb_memalloc() function.

It appears that Solaris assumes that the resulting memory is physically aligned based upon the
value of size. Make sure we also respect this alignment, so that memory allocated using this
interface can be correctly used for the Solaris IOMMU page tables.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>

Modified:
   trunk/openbios-devel/arch/sparc32/lib.c

Modified: trunk/openbios-devel/arch/sparc32/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/lib.c	Fri Feb 18 21:26:57 2011	(r1033)
+++ trunk/openbios-devel/arch/sparc32/lib.c	Fri Apr  8 11:03:59 2011	(r1034)
@@ -351,9 +351,28 @@
 {
     phys_addr_t phys;
     ucell virt;
+    unsigned long align;
+    int i;
+    
+    /* Solaris seems to assume that the returned value is physically aligned to size. For
+       example, not having this here causes the Solaris 8 kernel to fault because the 
+       IOMMU page table base address is calculated incorrectly. */
+
+    /* Enforce a minimum alignment of CONFIG_OFMEM_MALLOC_ALIGN, and choose an alignment 
+       which is the next power of 2 higher than the specified size */
+    align = size;
+    if (align <= CONFIG_OFMEM_MALLOC_ALIGN) {
+        align = CONFIG_OFMEM_MALLOC_ALIGN;
+    } else {
+        align--;
+        for (i = 1; i < sizeof(unsigned long) * 8; i<<=1) {
+            align |= align >> i;
+        }
+        align++;
+    }
 
     /* Claim physical memory */
-    phys = ofmem_claim_phys(-1, size, CONFIG_OFMEM_MALLOC_ALIGN);
+    phys = ofmem_claim_phys(-1, size, align);
 
     /* Claim virtual memory */
     virt = ofmem_claim_virt(pointer2cell(va), size, 0);



More information about the OpenBIOS mailing list