Understanding of high-end memory under IA-32 architecture

Preface: LinuxWhen I read the source code for the first time, I was worried about the role of high-end memory. When I read it for the second time, I CONFIG_HIGHMEMturned off the option by default and read it again. I also read many articles on the Internet. The definition of high-end memory is nothing more than what it is called 3G+896MB~4G. There is no easy-to-understand explanation.
The description of the huge Linuxsource code, whether in various video explanations or various books, is simply divided into various modules, and there is little or no information on how the various modules are connected to each other. This is difficult, extremely difficult. You have to understand it yourself and practice it to get your own so-called understanding.

Modular understanding of high-end memory

By default, 4G+this block is understood as high-end memory

Why is 4G+ high-end memory, VA or PA?

VA, here 4G+refers to the virtual address

We know that in IA-32the architecture, the virtual address space is 1:3divided according to the kernel, 1Gthat is, 3G~4G(note that the kernel does not care 0~3Gabout the process address space here), 32and the address line. When CPUanalyzing instructions, the virtual address space can always only be divided according to 4Gthe previous address, while the kernel occupies the middle and upper1G

Assuming that the 1Gvirtual memory of the kernel directly maps physical memory (regardless of the process address space), then the maximum physical address range mapped at this time should be. What 0~1Gif the physical memory is larger than this 1G? (The maximum virtual address space can only be 4G, no more can be added)

Then the concept of high-end memory comes on stage. All physical memory higher than 1Gthe physical memory is divided into high-end memory, but how to use it specifically?

It can be seen from the source code that during the kernel initialization process, a partner system ( buddy system) and a memory bitmap and a memory page map ( struct page) are initialized. They manage the allocation of all physical memory, including high-end memory.

The three mapping methods of high-end memory will not be discussed here. When accessing 3G+896MB~4Ga pair of virtual addresses, temporary mapping or page table technology is used to obtain the physical page from the partner system and establish mapping.

To sum it up: the virtual address space remains unchanged and the physical memory is variable.

Starlight does not care about those who are on the road, and time pays off to those who are willing to do so. Come on, everyone

Guess you like

Origin blog.csdn.net/qq_48322523/article/details/132073653