* [x86_64] Question about early page tables initialization
@ 2015-02-03 12:25 Alex Kuleshov
2015-02-03 12:42 ` Oren Twaig
0 siblings, 1 reply; 3+ messages in thread
From: Alex Kuleshov @ 2015-02-03 12:25 UTC (permalink / raw)
To: linux-kernel
Hello All,
I have a question about page tables initialization in the
arch/x86/boot/compressed/head_64.S
After we clear memory for page tables, there is code which
build PML4:
leal pgtable + 0(%ebx), %edi
leal 0x1007(%edi), %eax
movl %eax, 0(%edi)
Why there is offset 0x1007 instead just 0x7? 0x1007 is
4k + 7bit (PML4E) flags as i understand correctly. But
why we skip first 4k here?
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [x86_64] Question about early page tables initialization
2015-02-03 12:25 [x86_64] Question about early page tables initialization Alex Kuleshov
@ 2015-02-03 12:42 ` Oren Twaig
2015-02-03 13:00 ` Alexander Kuleshov
0 siblings, 1 reply; 3+ messages in thread
From: Oren Twaig @ 2015-02-03 12:42 UTC (permalink / raw)
To: Alex Kuleshov; +Cc: linux-kernel
Hi,
This is the corresponding C code which can help you understand:
u64 *pml4 = (u64*)pgtable;
u64 pdp = pgtable + 0x1000;
u64 pml4_entry = pdp | PTE_P | PTE_W | PTU; // present, write, userspace = 0x7
pml4[0] = pml4_entry;
The 0x1007 you see is just the calculation of the pml4_entry.
Oren Twaig.
On 02/03/2015 02:25 PM, Alex Kuleshov wrote:
> Hello All,
>
> I have a question about page tables initialization in the
> arch/x86/boot/compressed/head_64.S
>
> After we clear memory for page tables, there is code which
> build PML4:
>
> leal pgtable + 0(%ebx), %edi
> leal 0x1007(%edi), %eax
> movl %eax, 0(%edi)
>
> Why there is offset 0x1007 instead just 0x7? 0x1007 is
> 4k + 7bit (PML4E) flags as i understand correctly. But
> why we skip first 4k here?
>
> Thank you.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [x86_64] Question about early page tables initialization
2015-02-03 12:42 ` Oren Twaig
@ 2015-02-03 13:00 ` Alexander Kuleshov
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Kuleshov @ 2015-02-03 13:00 UTC (permalink / raw)
To: Oren Twaig; +Cc: linux-kernel
Hello Oren,
Ah yes, absolutely right. I thought almost the same, just overlooked
that pdp is right after pml4 in memory.
Oren thank you for help.
2015-02-03 18:42 GMT+06:00 Oren Twaig <oren@scalemp.com>:
> Hi,
>
> This is the corresponding C code which can help you understand:
>
> u64 *pml4 = (u64*)pgtable;
> u64 pdp = pgtable + 0x1000;
> u64 pml4_entry = pdp | PTE_P | PTE_W | PTU; // present, write, userspace = 0x7
> pml4[0] = pml4_entry;
>
> The 0x1007 you see is just the calculation of the pml4_entry.
>
> Oren Twaig.
>
> On 02/03/2015 02:25 PM, Alex Kuleshov wrote:
>> Hello All,
>>
>> I have a question about page tables initialization in the
>> arch/x86/boot/compressed/head_64.S
>>
>> After we clear memory for page tables, there is code which
>> build PML4:
>>
>> leal pgtable + 0(%ebx), %edi
>> leal 0x1007(%edi), %eax
>> movl %eax, 0(%edi)
>>
>> Why there is offset 0x1007 instead just 0x7? 0x1007 is
>> 4k + 7bit (PML4E) flags as i understand correctly. But
>> why we skip first 4k here?
>>
>> Thank you.
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>>
>
>
--
_________________________
0xAX
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-03 13:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-03 12:25 [x86_64] Question about early page tables initialization Alex Kuleshov
2015-02-03 12:42 ` Oren Twaig
2015-02-03 13:00 ` Alexander Kuleshov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).