I'm playing with setting the pml4 to point to itself and really just coming to terms with how that works. I didn't use this idea in my 32bit kernel. As I understand it, the space from 0xffff ff80 0000 0000 to 0xffff ffff ffff ffff will be taken by page tables. But I'm building my kernel with "-mcmodel=kernel" and my kernel entry point is 0xffff ffff 8000 0000.
Are these two things (self-referencing tables and -2GB kernel) mutually exclusive ?
Thanks in advance
Self-referencing pm4l and -2GB kernel
Self-referencing pm4l and -2GB kernel
If a trainstation is where trains stop, what is a workstation ?
Re: Self-referencing pm4l and -2GB kernel
Of course not. Just use any of the other 511 entries. For example, use entry 510, placing your page tables at 0xffffff00 00000000 through 0xffffff7f ffffffff.
Re: Self-referencing pm4l and -2GB kernel
Thanks Gigasoft! I can't believe it's that simple. Well, of course I believe it, but I'm off to draw a diagram anyway.
If a trainstation is where trains stop, what is a workstation ?
Re: Self-referencing pm4l and -2GB kernel
Okay. Please tell me whether I've understood this at least a little bit. I feel confused by the so-called recursive nature of what happens here. I suspect I'm not going to understand it fully until I've got it somewhat working and can actually see what's happening. Remember my kernel is the -2GB type.
My 2 assumptions:
1. I'm going to make it so that pm4l[510] contains the physical address of pm4l.
2. I'm going to put the pm4l table at virtual address 0xFFFFFF7F FFFFF000. <<<<---- edit - incorrect!!
Is that correct ?
It just doesn't seem right. In the scheme where [511] is used, [511] is used at each level recursively. But if I use [510] at the top level doesn't that mean I need to use [510] at the lower levels as well ? Does anyone know what I mean ? That would mean my pm4l table is at virtual address 0xFFFFFF7F BFDFE000.
My 2 assumptions:
1. I'm going to make it so that pm4l[510] contains the physical address of pm4l.
2. I'm going to put the pm4l table at virtual address 0xFFFFFF7F FFFFF000. <<<<---- edit - incorrect!!
Is that correct ?
Code: Select all
0xFFFFFF7F FFFFF000 to 0xFFFFFF7F FFFFFFFF - mapping of all page map level 4 entries in the address space
0xFFFFFF7F FFE00000 to 0xFFFFFF7F FFFFFFFF - mapping of all page directory pointer table entries in the address space
0xFFFFFF7F C0000000 to 0xFFFFFF7F FFFFFFFF - mapping of all page directory entries in the address space
0xFFFFFF00 00000000 to 0xFFFFFF7F FFFFFFFF - mapping of all page table entries in the address space
Last edited by gerryg400 on Thu May 27, 2010 9:37 am, edited 1 time in total.
If a trainstation is where trains stop, what is a workstation ?
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: Self-referencing pm4l and -2GB kernel
Indeed, it does. The page table layout gets a bit mixed up...gerryg400 wrote:But if I use [510] at the top level doesn't that mean I need to use [510] at the lower levels as well ? Does anyone know what I mean ? That would mean my pm4l table is at virtual address 0xFFFFFF7F BFDFE000.
Re: Self-referencing pm4l and -2GB kernel
Thanks XenOs. These are my calculations using 510 as the recursive slot number. Can anyone confirm that I'm on the right track with this. It's just starting to make sense I think.
Thanks in advance
Code: Select all
0xFFFFFF7F BFDFE000 to 0xFFFFFF7F BFDFEFFF - mapping of all page map level 4 entries in the address space
0xFFFFFF7F BFC00000 to 0xFFFFFF7F BFDFFFFF - mapping of all page directory pointer table entries in the address space
0xFFFFFF7F 80000000 to 0xFFFFFF7F BFFFFFFF - mapping of all page directory entries in the address space
0xFFFFFF00 00000000 to 0xFFFFFF7F FFFFFFFF - mapping of all page table entries in the address space
If a trainstation is where trains stop, what is a workstation ?
Re: Self-referencing pm4l and -2GB kernel
For anyone who searches and finds this thread, I have my mm working again and those addresses appear correct. I used the following macros to find the arrays
- gerryg400
Code: Select all
#define RECURSIVE_SLOT (510L)
#define L4_SHIFT (39)
#define L3_SHIFT (30)
#define L2_SHIFT (21)
#define L1_SHIFT (12)
#define UPPER_ADDR(x) ((uint64_t*)(0xffffL<<48|(x)))
#define PGTBL_ADDR UPPER_ADDR((RECURSIVE_SLOT<<L4_SHIFT))
#define PGDIR_ADDR UPPER_ADDR((RECURSIVE_SLOT<<L4_SHIFT) \
|(RECURSIVE_SLOT<<L3_SHIFT))
#define PDPT_ADDR UPPER_ADDR((RECURSIVE_SLOT<<L4_SHIFT) \
|(RECURSIVE_SLOT<<L3_SHIFT) \
|(RECURSIVE_SLOT<<L2_SHIFT))
#define PML4T_ADDR UPPER_ADDR((RECURSIVE_SLOT<<L4_SHIFT) \
|(RECURSIVE_SLOT<<L3_SHIFT) \
|(RECURSIVE_SLOT<<L2_SHIFT) \
|(RECURSIVE_SLOT<<L1_SHIFT))
If a trainstation is where trains stop, what is a workstation ?
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: Self-referencing pm4l and -2GB kernel
Looks fine to me. It's probably a bit confusing at first sight because the higher level page tables are somewhere in the middle of the lower order page tables, but this is exactly how it works in this case.gerryg400 wrote:These are my calculations using 510 as the recursive slot number. Can anyone confirm that I'm on the right track with this.