Closed tomuta closed 4 years ago
Tried this in kmalloc.cpp, but for some reason end_of_kernel_bss
is always 0?
extern u32 end_of_kernel_bss;
#define BASE_PHYSICAL ((u8*)PAGE_ROUND_UP(end_of_kernel_bss))
#define ETERNAL_BASE_PHYSICAL (BASE_PHYSICAL + POOL_SIZE)
Doh, it has to be &end_of_kernel_bss
, not end_of_kernel_bss
...
Trying to figure out some odd bugs related to #3229, I found that global variables are crossing into
ETERNAL_BASE_PHYSICAL
, which causes random memory corruption. One issue similar (though I don't believe the same) is related to the kernel command line getting corrupted, which is solved in a commit in #3248. However, I'm not sure how to solve this issue deterministically. It seems likeBASE_PHYSICAL
andETERNAL_BASE_PHYSICAL
need to account for global variables and other stuff. Maybe it should start no lower thanend_of_kernel_image
?This is an example of what can happen:
In this case,
0xc0200000
is the first slab in the 16 byte allocator, which happened to be allocated to aPhysicalPage
, but this call tokmalloc
corrupted it because the global variablealloc_bitmap
happened to be located at0xc01ff200-0xc0202200
.