From 968ab15bbb4874a0ce0ddc80020a598dbb580ee7 Mon Sep 17 00:00:00 2001 From: Reto Buerki Date: Fri, 27 Feb 2015 10:40:34 +0100 Subject: [PATCH] hw_x86_64: Add Genode::Gdt class The class provides the load() function which reloads the GDTR with the GDT address in the mtc region. This is needed to make the segments accessible to non-core threads. Make the _gdt_start label global to use it in the call to _virt_mtc_addr(). --- .../src/core/include/spec/x86_64/gdt.h | 34 +++++++++++++++++++ .../src/core/spec/x86_64/mode_transition.s | 1 + 2 files changed, 35 insertions(+) create mode 100644 repos/base-hw/src/core/include/spec/x86_64/gdt.h diff --git a/repos/base-hw/src/core/include/spec/x86_64/gdt.h b/repos/base-hw/src/core/include/spec/x86_64/gdt.h new file mode 100644 index 000000000..21ca6e4e4 --- /dev/null +++ b/repos/base-hw/src/core/include/spec/x86_64/gdt.h @@ -0,0 +1,34 @@ +#ifndef _GDT_H_ +#define _GDT_H_ + +#include +#include + +extern int _gdt_start; + +namespace Genode +{ + /** + * Global Descriptor Table (GDT) + * See Intel SDM Vol. 3A, section 3.5.1 + */ + class Gdt; +} + +class Genode::Gdt +{ + public: + + /** + * Load GDT from mtc region into GDTR. + * + * \param virt_base virtual base address of mode transition pages + */ + static void load(addr_t const virt_base) + { + asm volatile ("lgdt %0" : : "m" (Pseudo_descriptor (0x37, + _virt_mtc_addr(virt_base, (addr_t)&_gdt_start)))); + } +}; + +#endif /* _GDT_H_ */ diff --git a/repos/base-hw/src/core/spec/x86_64/mode_transition.s b/repos/base-hw/src/core/spec/x86_64/mode_transition.s index ae5e9426d..566b91de7 100644 --- a/repos/base-hw/src/core/spec/x86_64/mode_transition.s +++ b/repos/base-hw/src/core/spec/x86_64/mode_transition.s @@ -269,6 +269,7 @@ .space 2 .global _gdt_ptr + .global _gdt_start _gdt_ptr: .word _gdt_end - _gdt_start - 1 /* limit */ .long _gdt_start /* base address */