0

In 32 bit systems with more than 896 MB of RAM it is obvious, that the mapping of kernel addresses need to be changed because of kernel virtual addresses and the non-continuous mapping.

But how is this handled in 64 bit? As the RAM can always be mapped entirely in the address space, the master kernel page table needs to be set up once at initialization and then is never changed, since the mapping is never changed. Thus, this kernel region in the user page table never needs to be updated?

Btw has someone a good explanation how the user process page tables are updated in 32 bit? As it is always said, that the master kernel page tables are not directly used but only used as a reference. Are the entries for the kernel region copied for every process in its user page table?

2

In 32 bit systems with more than 896 MB of RAM it is obvious, that the mapping of kernel addresses need to be changed because of kernel virtual addresses and the non-continuous mapping.

Yes, this is known as highmem.

But how is this handled in 64 bit? As the RAM can always be mapped entirely in the address space, the master kernel page table needs to be set up once at initialization and then is never changed, since the mapping is never changed. Thus, this kernel region in the user page table never needs to be updated?

Yes.

Btw has someone a good explanation how the user process page tables are updated in 32 bit? As it is always said, that the master kernel page tables are not directly used but only used as a reference. Are the entries for the kernel region copied for every process in its user page table?

In the highmem document linked above, it says that highmem mappings only require manipulating "the kernel's page tables".

"Page tables" are actually a type of tree structure. E.g. see https://lwn.net/Articles/106177/ . The top level is a single page (4096 bytes). The entries which map the kernel range, are set to the same values in all processes, and hence are shared. The temporary mappings happen at a lower level of the tree, so they only need to modify inside the shared kernel page tables, and they do not need to modify each process page table separately.

At least, that's my high-level overview. I don't have all the words.

  • Thanks for your answer! It solved the main part. I figured out what you said in the last part, too, but I was confused because it is said, that the kernel master page tables are not directly used. Maybe it is only terminology. So the entries in every user page table that map kernel virtual addresses point to the kernel page table. I know the structure of pages and multilevel paging, but simply said. – pudi Apr 18 at 11:55
  • @pudi I guess that swapper_pg_dir points to a top-level page table, that is used to keep track of the "kernel page tables", but we never tell the CPU(s) to use swapper_pg_dir. We just copy the kernel range from it into the top-level of the page table of each process. I think you can get an idea from looking at this function: elixir.bootlin.com/linux/v5.0/source/arch/x86/mm/pgtable.c#L305 – sourcejedi Apr 18 at 12:00
  • That is the perfect answer, thanks! – pudi Apr 18 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.