i think the problem is your memset is trying to 1. doesnt have enough space to allocate or 2. the memory got corrupted somehow. you may even mallocated more memory for the kernel directory than you can, but thats the only things i can think of. when dealing with low level stuff it is hard to debug. the mapping may not be correct, im sorry i couldnt answer tho