summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-03-29 12:35:47 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-03-29 12:37:22 +0200
commit591e5554bf6635be83920521c0e9a53974370aa2 (patch)
treed44bc38b1094c088468bb3166ad5831bb87d7567
parenta22e4d82f6bb6ff36e2ee0199120012623442244 (diff)
64bit: Fix segment definitions
* i386/i386/gdt.c: Include <kern/assert.h> (gdt_init) [__x86_64__]: Assert base is 0, pass 0 limit and 64bit size. * i386/i386/ktss.c: Warn that it needs to be fixed. * i386/i386/ldt.c: Warn that it needs to be fixed. * i386/i386/mp_desc.c: Warn that it needs to be fixed.
-rw-r--r--i386/i386/gdt.c10
-rw-r--r--i386/i386/ktss.c4
-rw-r--r--i386/i386/ldt.c4
-rw-r--r--i386/i386/mp_desc.c3
4 files changed, 21 insertions, 0 deletions
diff --git a/i386/i386/gdt.c b/i386/i386/gdt.c
index bc36031b..fb18360e 100644
--- a/i386/i386/gdt.c
+++ b/i386/i386/gdt.c
@@ -33,6 +33,7 @@
#include <mach/machine/vm_types.h>
#include <mach/xen.h>
+#include <kern/assert.h>
#include <intel/pmap.h>
#include "vm_param.h"
@@ -49,6 +50,14 @@ void
gdt_init(void)
{
/* Initialize the kernel code and data segment descriptors. */
+#ifdef __x86_64__
+ assert(LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS == 0);
+ fill_gdt_descriptor(KERNEL_CS, 0, 0, ACC_PL_K|ACC_CODE_R, SZ_64);
+ fill_gdt_descriptor(KERNEL_DS, 0, 0, ACC_PL_K|ACC_DATA_W, SZ_64);
+#ifndef MACH_PV_DESCRIPTORS
+ fill_gdt_descriptor(LINEAR_DS, 0, 0, ACC_PL_K|ACC_DATA_W, SZ_64);
+#endif /* MACH_PV_DESCRIPTORS */
+#else
fill_gdt_descriptor(KERNEL_CS,
LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS,
LINEAR_MAX_KERNEL_ADDRESS - (LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) - 1,
@@ -63,6 +72,7 @@ gdt_init(void)
0xffffffff,
ACC_PL_K|ACC_DATA_W, SZ_32);
#endif /* MACH_PV_DESCRIPTORS */
+#endif
#ifdef MACH_PV_DESCRIPTORS
unsigned long frame = kv_to_mfn(gdt);
diff --git a/i386/i386/ktss.c b/i386/i386/ktss.c
index 21d00300..62de2a27 100644
--- a/i386/i386/ktss.c
+++ b/i386/i386/ktss.c
@@ -51,6 +51,10 @@ ktss_init(void)
if (hyp_stack_switch(KERNEL_DS, (unsigned long)(exception_stack+1024)))
panic("couldn't register exception stack\n");
#else /* MACH_RING1 */
+
+#ifdef __x86_64__
+#warning FIXME
+#endif
/* Initialize the master TSS descriptor. */
fill_gdt_descriptor(KERNEL_TSS,
kvtolin(&ktss), sizeof(struct task_tss) - 1,
diff --git a/i386/i386/ldt.c b/i386/i386/ldt.c
index 0250ee26..99d2f7fe 100644
--- a/i386/i386/ldt.c
+++ b/i386/i386/ldt.c
@@ -47,6 +47,10 @@ struct real_descriptor ldt[LDTSZ];
void
ldt_init(void)
{
+#ifdef __x86_64__
+#warning FIXME
+#endif
+
#ifdef MACH_PV_DESCRIPTORS
#ifdef MACH_PV_PAGETABLES
pmap_set_page_readwrite(ldt);
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index 6aa8e664..d62d4958 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -146,6 +146,9 @@ mp_desc_init(int mycpu)
#ifdef MACH_RING1
panic("TODO %s:%d\n",__FILE__,__LINE__);
#else /* MACH_RING1 */
+#ifdef __x86_64__
+#warning FIXME
+#endif
fill_descriptor(&mpt->gdt[sel_idx(KERNEL_LDT)],
(unsigned)&mpt->ldt,
LDTSZ * sizeof(struct real_descriptor) - 1,