From 2ffa516d898c28ec0122da2cfe59121381ef4fe5 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Wed, 16 Nov 2016 11:42:03 -0800 Subject: [PATCH] x86: set accessed bit in ROM-based GDT Previous configuration was backwards. From the Intel manual: "If the segment descriptors in the GDT or an LDT are placed in ROM, the processor can enter an indefinite loop if software or the processor attempts to update (write to) the ROM-based segment descriptors. To prevent this problem, set the accessed bits for all segment descriptors placed in a ROM. Also, remove operating-system or executive code that attempts to modify segment descriptors located in ROM." Only by some miracle has this not been causing problems. Change-Id: I0bb915962a1069876d2486473760112102feae7b Signed-off-by: Andrew Boie --- arch/x86/core/crt0.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/core/crt0.S b/arch/x86/core/crt0.S index 28d04c77429..497898fb14b 100644 --- a/arch/x86/core/crt0.S +++ b/arch/x86/core/crt0.S @@ -379,9 +379,10 @@ _Idt: * exceptions even if physical memory does not reside at the referenced * address. * - * The 'A' (accessed) bit in the type field is _not_ set for all the + * The 'A' (accessed) bit in the type field is set for all the * data/code segment descriptors to accommodate placing these entries - * in ROM, since such use is not planned for this platform. + * in ROM, to prevent the processor from freaking out when it tries + * and fails to set it. */ #ifndef CONFIG_GDT_DYNAMIC @@ -401,7 +402,7 @@ _gdt_rom: .word 0xffff /* limit: xffff */ .word 0x0000 /* base : xxxx0000 */ .byte 0x00 /* base : xx00xxxx */ - .byte 0x9a /* Code e/r, Present, DPL0 */ + .byte 0x9b /* Accessed, Code e/r, Present, DPL0 */ .byte 0xcf /* limit: fxxxx, Page Gra, 32bit */ .byte 0x00 /* base : 00xxxxxx */ @@ -410,7 +411,7 @@ _gdt_rom: .word 0xffff /* limit: xffff */ .word 0x0000 /* base : xxxx0000 */ .byte 0x00 /* base : xx00xxxx */ - .byte 0x92 /* Data r/w, Present, DPL0 */ + .byte 0x93 /* Accessed, Data r/w, Present, DPL0 */ .byte 0xcf /* limit: fxxxx, Page Gra, 32bit */ .byte 0x00 /* base : 00xxxxxx */