support IA-32e's "execute disable bit"
This commit is contained in:
@@ -311,9 +311,45 @@ static void enable_page_protection_fault(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static int no_execute_available = 0;
|
||||
|
||||
static void enable_no_execute(void)
|
||||
{
|
||||
unsigned long efer;
|
||||
|
||||
if (!no_execute_available) {
|
||||
return;
|
||||
}
|
||||
|
||||
efer = rdmsr(MSR_EFER);
|
||||
#define IA32_EFER_NXE (1UL << 11)
|
||||
efer |= IA32_EFER_NXE;
|
||||
wrmsr(MSR_EFER, efer);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void check_no_execute(void)
|
||||
{
|
||||
uint32_t edx;
|
||||
extern void enable_ptattr_no_execute(void);
|
||||
|
||||
/* check Execute Disable Bit available bit */
|
||||
asm ("cpuid" : "=d" (edx) : "a" (0x80000001) : "%rbx", "%rcx");
|
||||
no_execute_available = (edx & (1 << 20))? 1: 0;
|
||||
kprintf("no_execute_available: %d\n", no_execute_available);
|
||||
|
||||
if (no_execute_available) {
|
||||
enable_ptattr_no_execute();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void init_cpu(void)
|
||||
{
|
||||
enable_page_protection_fault();
|
||||
enable_no_execute();
|
||||
init_fpu();
|
||||
init_lapic();
|
||||
init_syscall();
|
||||
@@ -330,6 +366,8 @@ void setup_x86(void)
|
||||
|
||||
init_page_table();
|
||||
|
||||
check_no_execute();
|
||||
|
||||
init_cpu();
|
||||
|
||||
kprintf("setup_x86 done.\n");
|
||||
|
||||
Reference in New Issue
Block a user