Revert "bank8k: Fix program size/top confusion"
authorAlan Cox <alan@linux.intel.com>
Sun, 16 Sep 2018 22:13:18 +0000 (23:13 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 16 Sep 2018 22:13:18 +0000 (23:13 +0100)
This reverts commit 90a1fcf7d46e10e3e163d11785badda0c8f5ba2a.

The original logic is actually correct I believe on review. The top is
turned into a size, biased by the need to keep space for the common copy
and correctly calculated

Kernel/bank8k.c

index bc1d0ee..b88a2fa 100644 (file)
@@ -109,11 +109,11 @@ void pagemap_free(ptptr p)
        }
 }
 
-static int maps_needed(uint16_t size)
+static int maps_needed(uint16_t top)
 {
        /* On many platforms if you touch this or PROGTOP you must
           touch tricks.s */
-       uint16_t needed = size - 1;
+       uint16_t needed = top + 0xFFFF - PROGTOP;
        /* Usually we have 0x1000 common - 1 for shift and inc */
        needed >>= 13;          /* in banks */
        needed++;               /* rounded */
@@ -130,7 +130,7 @@ static int maps_needed(uint16_t size)
 int pagemap_alloc(ptptr p)
 {
        uint8_t *ptr;
-       int needed = maps_needed(p->p_top - MAPBASE);
+       int needed = maps_needed(p->p_top);
        int i;
 
        /* Cheapest way to keep it non zero */
@@ -165,7 +165,7 @@ int pagemap_alloc(ptptr p)
  */
 int pagemap_realloc(usize_t code, usize_t size, usize_t stack)
 {
-       int8_t have = maps_needed(udata.u_top - MAPBASE);
+       int8_t have = maps_needed(udata.u_top);
        int8_t want = maps_needed(size);
        uint8_t *ptr = (uint8_t *)udata.u_page;