Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/amd64.c

    r811770c raf9dd1e  
    6464#endif
    6565
     66/** Disable I/O on non-privileged levels
     67 *
     68 * Clean IOPL(12,13) and NT(14) flags in EFLAGS register
     69 */
     70static void clean_IOPL_NT_flags(void)
     71{
     72        asm volatile (
     73                "pushfq\n"
     74                "pop %%rax\n"
     75                "and $~(0x7000), %%rax\n"
     76                "pushq %%rax\n"
     77                "popfq\n"
     78                ::: "%rax"
     79        );
     80}
     81
     82/** Disable alignment check
     83 *
     84 * Clean AM(18) flag in CR0 register
     85 */
     86static void clean_AM_flag(void)
     87{
     88        asm volatile (
     89                "mov %%cr0, %%rax\n"
     90                "and $~(0x40000), %%rax\n"
     91                "mov %%rax, %%cr0\n"
     92                ::: "%rax"
     93        );
     94}
     95
    6696/** Perform amd64-specific initialization before main_bsp() is called.
    6797 *
     
    86116{
    87117        /* Enable no-execute pages */
    88         write_msr(AMD_MSR_EFER, read_msr(AMD_MSR_EFER) | AMD_NXE);
     118        set_efer_flag(AMD_NXE_FLAG);
    89119        /* Enable FPU */
    90120        cpu_setup_fpu();
     
    93123        pm_init();
    94124       
    95         /* Disable I/O on nonprivileged levels, clear the nested-thread flag */
    96         write_rflags(read_rflags() & ~(RFLAGS_IOPL | RFLAGS_NT));
     125        /* Disable I/O on nonprivileged levels
     126         * clear the NT (nested-thread) flag
     127         */
     128        clean_IOPL_NT_flags();
    97129        /* Disable alignment check */
    98         write_cr0(read_cr0() & ~CR0_AM);
     130        clean_AM_flag();
    99131       
    100132        if (config.cpu_active == 1) {
Note: See TracChangeset for help on using the changeset viewer.