I know how to translate a virtual address to a physical address, but is it possible to take one desired VA and if you detect that it's PTE (or PDE or PTPE or PML4E) is not present to actually map it to a right physical address?
Let's take for example VA 0x30000 on an x86 non-PAE Windows system. Splitting it into 3 groups we have
0000000000 | 0000110000 | 000000000000
Page Directory Index = 0x0
Page Table Index = 0x30
Physical Offset = 0x0
We get PD's physical address from CR3 and discover that it's PDE has the Present bit cleared. Is it possible to write in physical memory (at pd[pdi]) a valid PDE (in essence, set the Present bit) and then traverse all the tables (marking entries as present) and finally had the VA to be valid for a certain PA so that future attempts at translating it will be successful? Can one even write directly to a physical address from a kernel module?