Changeset 720db0c in mainline for kernel/arch/ia32/src/mm/frame.c


Ignore:
Timestamp:
2010-06-26T23:00:54Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
68667ce
Parents:
cae5404
Message:

fix erroneous resizing of physical zones (ticket #240)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/mm/frame.c

    rcae5404 r720db0c  
    4747#include <print.h>
    4848
    49 #define PHYSMEM_LIMIT  0x7C000000
     49#define PHYSMEM_LIMIT  0x7C000000ull
    5050
    5151size_t hardcoded_unmapped_ktext_size = 0;
     
    8888#endif
    8989               
    90                 pfn_t pfn;
    91                 size_t count;
    92                
    9390                if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
    94                         /* To be safe, make available zone possibly smaller */
    95                         pfn = ADDR2PFN(ALIGN_UP(base, FRAME_SIZE));
    96                         count = SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE));
     91                        /* To be safe, make the available zone possibly smaller */
     92                        uint64_t new_base = ALIGN_UP(base, FRAME_SIZE);
     93                        uint64_t new_size = ALIGN_DOWN(size - (new_base - base),
     94                            FRAME_SIZE);
     95                       
     96                        pfn_t pfn = ADDR2PFN(new_base);
     97                        size_t count = SIZE2FRAMES(new_size);
    9798                       
    9899                        pfn_t conf;
     
    105106                       
    106107                        // XXX this has to be removed
    107                         if (last_frame < ALIGN_UP(base + size, FRAME_SIZE))
    108                                 last_frame = ALIGN_UP(base + size, FRAME_SIZE);
     108                        if (last_frame < ALIGN_UP(new_base + new_size, FRAME_SIZE))
     109                                last_frame = ALIGN_UP(new_base + new_size, FRAME_SIZE);
    109110                }
    110111               
    111112                if (e820table[i].type == MEMMAP_MEMORY_RESERVED) {
    112                         /* To be safe, make reserved zone possibly larger */
    113                         pfn = ADDR2PFN(ALIGN_DOWN(base, FRAME_SIZE));
    114                         count = SIZE2FRAMES(ALIGN_UP(size, FRAME_SIZE));
     113                        /* To be safe, make the reserved zone possibly larger */
     114                        uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
     115                        uint64_t new_size = ALIGN_UP(size + (base - new_base),
     116                            FRAME_SIZE);
    115117                       
    116                         zone_create(pfn, count, 0, ZONE_RESERVED);
     118                        zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
     119                            ZONE_RESERVED);
    117120                }
    118121               
    119122                if (e820table[i].type == MEMMAP_MEMORY_ACPI) {
    120                         /* To be safe, make firmware zone possibly larger */
    121                         pfn = ADDR2PFN(ALIGN_DOWN(base, (uintptr_t) FRAME_SIZE));
    122                         count = SIZE2FRAMES(ALIGN_UP(size, (uintptr_t) FRAME_SIZE));
     123                        /* To be safe, make the firmware zone possibly larger */
     124                        uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
     125                        uint64_t new_size = ALIGN_UP(size + (base - new_base),
     126                            FRAME_SIZE);
    123127                       
    124                         zone_create(pfn, count, 0, ZONE_FIRMWARE);
     128                        zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
     129                            ZONE_FIRMWARE);
    125130                }
    126131        }
Note: See TracChangeset for help on using the changeset viewer.