x86_64: pmap: enable NX protection during bootstrap
This commit is contained in:
@@ -50,5 +50,6 @@ typedef enum page_size {
|
||||
/* returns 1 if gigabyte pages are supported by the CPU, 0 otherwise.
|
||||
defined in pmap_ctrl.S */
|
||||
extern int gigabyte_pages(void);
|
||||
extern int enable_nx(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -226,6 +226,8 @@ void pmap_bootstrap(void)
|
||||
{
|
||||
can_use_gbpages = gigabyte_pages();
|
||||
printk("pmap: gigabyte pages %sabled", can_use_gbpages == 1 ? "en" : "dis");
|
||||
enable_nx();
|
||||
printk("pmap: NX protection enabled");
|
||||
|
||||
page_size_t hugepage = PS_2M;
|
||||
if (can_use_gbpages) {
|
||||
|
||||
@@ -29,3 +29,14 @@ gigabyte_pages:
|
||||
3: pop %rbx
|
||||
pop %rbp
|
||||
ret
|
||||
|
||||
.global enable_nx
|
||||
.type enable_nx, @function
|
||||
|
||||
enable_nx:
|
||||
mov $0xC0000080, %ecx
|
||||
rdmsr
|
||||
or $0x800, %eax
|
||||
wrmsr
|
||||
|
||||
ret
|
||||
|
||||
Reference in New Issue
Block a user