Can Kernel use virtual memory In Linux [duplicate]
My question is whether linux kernel c开发者_运维问答an use virtual memory or does it always uses fixed memory? Another question is that if due to some soft error, the kernel memory is corrupted, what will happen then? Does Linux has any mechanism to protect itself from such faults?
Kernel uses virtual adresses. Allocated memory, function pointers etc... are all virtual adress. You only manipulate physical adress when speaking to some devices or when doing certain kind of DMA.
"Linux" or "The linux kernel" run on many architecture. Some of these architecture can have memory error detection or correction hardware. I don't know how these device are supported. But on most architecture, there is no protection against memory corruption.
But you are speaking of soft error. There is no protection from kernel code writing at random adresses. Some function test the parameters they get to catch bug, but if you overflow a buffer or the stack in kernel mode, then various funny things can happen.
Const data and code is usually placed in read-only pages, so that a write can be detected. The memory protection of the kernel is thus limited to :
- Parameter checking in some places.
- magic value in some structure.
- read only attribute for code and const sections.
read only attribute is only possible because the kernel uses virtual memory
精彩评论