Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
mrjbom
Member
Posts: 317 Joined: Sun Jul 21, 2019 7:34 am
Post
by mrjbom » Tue Jun 02, 2020 1:27 pm
Hi.
I try to get it with this kind of code
Code: Select all
uint32_t cr4 = 0;
__asm__ (
"mov %%cr4, %0" : "=r"(cr4)
);
dprintf("cr4 = %I\n", cr4);
for(int i = 0; i < 32; ++i) {
dprintf("%I", (cr4 >> i) & 1);
}
but I get 0, for cr0 it works.
kzinti
Member
Posts: 898 Joined: Mon Feb 02, 2015 7:11 pm
Post
by kzinti » Tue Jun 02, 2020 2:17 pm
Could it be that CR4 is indeed 0?
mrjbom
Member
Posts: 317 Joined: Sun Jul 21, 2019 7:34 am
Post
by mrjbom » Tue Jun 02, 2020 2:19 pm
kzinti wrote: Could it be that CR4 is indeed 0?
No, I have PAE enabled(GRUB includes it), so 5 bits should be equal to 1.
iansjack
Member
Posts: 4703 Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK
Post
by iansjack » Tue Jun 02, 2020 3:04 pm
Are you sure? I'm probably wrong, but I thought PAE was something that was enabled in the kernel, not the boot loader.
mrjbom
Member
Posts: 317 Joined: Sun Jul 21, 2019 7:34 am
Post
by mrjbom » Tue Jun 02, 2020 3:08 pm
iansjack wrote: Are you sure? I'm probably wrong, but I thought PAE was something that was enabled in the kernel, not the boot loader.
Hm.
the memory_map that GRUB gives me sees memory above 4 GB, I think it does it with PAE and expect to see it with this call.
Perhaps it is really disabled in the core.
kzinti
Member
Posts: 898 Joined: Mon Feb 02, 2015 7:11 pm
Post
by kzinti » Tue Jun 02, 2020 3:39 pm
No, Grub doesn't enable PAE for you. In fact, paging is not even enabled.
The fact that it reports memory above 4 GB has nothing to do with PAE being enabled or not.
You have to setup page tables for PAE and enable it yourself if you want to use it.
See
https://www.pvv.ntnu.no/~steinarh/grub/ ... html#SEC12 :
Paging must be turned off.
mrjbom
Member
Posts: 317 Joined: Sun Jul 21, 2019 7:34 am
Post
by mrjbom » Tue Jun 02, 2020 4:03 pm
kzinti wrote: No, Grub doesn't enable PAE for you. In fact, paging is not even enabled.
The fact that it reports memory above 4 GB has nothing to do with PAE being enabled or not.
You have to setup page tables for PAE and enable it yourself if you want to use it.
See
https://www.pvv.ntnu.no/~steinarh/grub/ ... html#SEC12 :
Paging must be turned off.
I understood. Thanks.