Skip to contentSkip to conversation

Problems setting up GDT in custom builder

DISCUSSION Ivan Kelly 1 participant 1 message Jan 26, 2006

lore
Share & tools
lore

Ivan Kelly

author
#0 lore raw

In having problems getting a custom built GDT which I set up in my custom builder to work. Im putting aside 16 frames for the GDT, and initialising it with the values that I need (one descriptor for CS at 6, one for DS at 3). The GDT seems to get getting the correct values. The CS segment is the same as the default FLAT_GUESTOS_CS. The DS is slightly different, since I need my data segment to start at 0x6000.
My GDT is at 0x593000 and gdb shows the contents of entry 3 and entry 260(FLAT_GUESTOS_DS) as follows.

(gdb) x/2x 0x593000+(0x3*0x8)
0x593018: 0x6000c3f9 0x00cfb300
(gdb) x/2x 0x593000+(260*0x8)
0x593820: 0x0000c3ff 0x00cfb300

Almost identical exept that base (B0-B15) are 6000. The limit is slightly different but that should affect anything.

I set the domain to use the new descriptors in the builder.

<SNIP>

         *       [ECX,EDX,EDI,EBP are zero]                                                          
         *       EFLAGS = IF | 2 (bit 1 is reserved and should always be 1)                          
         */
        ctxt->cpu_ctxt.ds = DS_SELECTOR; /*FLAT_GUESTOS_DS;*/
        ctxt->cpu_ctxt.es = FLAT_GUESTOS_DS;
        ctxt->cpu_ctxt.fs = FLAT_GUESTOS_DS;
        ctxt->cpu_ctxt.gs = FLAT_GUESTOS_DS;
        ctxt->cpu_ctxt.ss = FLAT_GUESTOS_DS;
        ctxt->cpu_ctxt.cs = CS_SELECTOR; /*FLAT_GUESTOS_CS;*/
        ctxt->cpu_ctxt.eip = dsi.processes[KERNEL].entry;

<ENDSNIP>

<SNIP2>

#define DS_SELECTOR         0x19  /* 00011 | 001 */
#define CS_SELECTOR         0x31  /* 00110 | 001 */

<ENDSNIP2>

full source:
http://secure.bleurgh.com/svn/xen/trunk/tools/libxc/xc_minix_build.c

To me this looks like it should work perfectly, but when I try to run my kernel on it, mov instructions seem to be using 0x0 (physical addr) as their base.

Could anyone point out my mistake. It's driving me nuts :) Regards
Ivan Kelly