[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Cleaner GDT interface. Xen now reserves the last 2 pages of a full-size



ChangeSet 1.1443, 2005/05/18 14:12:57+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Cleaner GDT interface. Xen now reserves the last 2 pages of a full-size
        (16 page) GDT. A guest can register a GDT with up to 7k entries. Xen
        automatically makes the GDT up to max size with empty page mappings,
        and turns page faults in that area to #GP(selector).
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/machdep.c           |    8 
 b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/mp_machdep.c        |    2 
 b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c       |    3 
 b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/segment.h   |    4 
 b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/segment.h |    2 
 b/netbsd-2.0-xen-sparse/sys/arch/xen/i386/machdep.c            |    4 
 b/tools/libxc/xc_linux_restore.c                               |    7 
 b/xen/arch/x86/boot/x86_32.S                                   |   34 +-
 b/xen/arch/x86/boot/x86_64.S                                   |   75 +++---
 b/xen/arch/x86/dom0_ops.c                                      |   10 
 b/xen/arch/x86/domain.c                                        |  108 +++++----
 b/xen/arch/x86/domain_build.c                                  |    3 
 b/xen/arch/x86/mm.c                                            |   63 +----
 b/xen/arch/x86/setup.c                                         |   24 +-
 b/xen/arch/x86/trampoline.S                                    |    7 
 b/xen/arch/x86/traps.c                                         |  117 
++++++----
 b/xen/arch/x86/x86_32/seg_fixup.c                              |   14 -
 b/xen/arch/x86/x86_32/traps.c                                  |    5 
 b/xen/include/asm-x86/config.h                                 |   28 +-
 b/xen/include/asm-x86/desc.h                                   |   23 +
 b/xen/include/asm-x86/domain.h                                 |    2 
 b/xen/include/asm-x86/ldt.h                                    |    2 
 b/xen/include/asm-x86/mm.h                                     |    3 
 b/xen/include/asm-x86/processor.h                              |    9 
 b/xen/include/public/arch-x86_32.h                             |   28 --
 b/xen/include/public/arch-x86_64.h                             |   25 --
 xen/include/asm-x86/x86_64/ldt.h                               |   39 ---
 27 files changed, 292 insertions(+), 357 deletions(-)


diff -Nru a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/machdep.c 
b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/machdep.c
--- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/machdep.c        2005-05-18 
10:05:49 -04:00
+++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/machdep.c        2005-05-18 
10:05:49 -04:00
@@ -1599,11 +1599,7 @@
        gdt_segs[GDATA_SEL].ssd_limit = atop(0 - ((1 << 26) - (1 << 22) + (1 << 
16))); 
 #endif
 #ifdef SMP
-       /* XXX this will blow up if there are more than 512/NGDT vcpus - will 
never 
-        * be an issue in the real world but should add an assert on general 
principles
-        * we'll likely blow up when we hit LAST_RESERVED_GDT_ENTRY, at which 
point we
-        * would need to start allocating more pages for the GDT
-        */
+       /* XXX this will blow up if there are more than 512/NGDT vcpus */
        pc = &SMP_prvspace[0].pcpu;
        for (i = 0; i < ncpus; i++) {
                cpu_add(i, (i == 0));
@@ -1633,7 +1629,7 @@
 
        PT_SET_MA(gdt, *vtopte((unsigned long)gdt) & ~PG_RW);
        gdtmachpfn = vtomach(gdt) >> PAGE_SHIFT;
-       PANIC_IF(HYPERVISOR_set_gdt(&gdtmachpfn, LAST_RESERVED_GDT_ENTRY + 1) 
!= 0);
+       PANIC_IF(HYPERVISOR_set_gdt(&gdtmachpfn, 512) != 0);
 
        
        lgdt_finish();
diff -Nru a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/mp_machdep.c 
b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/mp_machdep.c
--- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/mp_machdep.c     2005-05-18 
10:05:52 -04:00
+++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/mp_machdep.c     2005-05-18 
10:05:52 -04:00
@@ -533,7 +533,7 @@
        myid = bootAP;
 
        gdtmachpfn = vtomach(gdt) >> PAGE_SHIFT;
-       PANIC_IF(HYPERVISOR_set_gdt(&gdtmachpfn, LAST_RESERVED_GDT_ENTRY + 1) 
!= 0); 
+       PANIC_IF(HYPERVISOR_set_gdt(&gdtmachpfn, 512) != 0); 
 
        
        lgdt_finish();
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c 
b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c
--- a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c    2005-05-18 
10:05:49 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c    2005-05-18 
10:05:49 -04:00
@@ -856,9 +856,6 @@
        cpu_gdt_descr[cpu].size = cpu_gdt_descr[0].size;
        memcpy((void *)cpu_gdt_descr[cpu].address,
               (void *)cpu_gdt_descr[0].address, cpu_gdt_descr[0].size);
-               memset((char *)cpu_gdt_descr[cpu].address +
-                      FIRST_RESERVED_GDT_ENTRY * 8, 0,
-                      NR_RESERVED_GDT_ENTRIES * 8);
 
        memset(&ctxt, 0, sizeof(ctxt));
 
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/segment.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/segment.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/segment.h        
2005-05-18 10:05:49 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/segment.h        
2005-05-18 10:05:49 -04:00
@@ -74,9 +74,9 @@
 #define GDT_ENTRY_DOUBLEFAULT_TSS      31
 
 /*
- * The GDT has LAST_RESERVED_GDT_ENTRY + 1 entries
+ * The GDT has 32 entries
  */
-#define GDT_ENTRIES (LAST_RESERVED_GDT_ENTRY + 1)
+#define GDT_ENTRIES 32
 
 #define GDT_SIZE (GDT_ENTRIES * 8)
 
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/segment.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/segment.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/segment.h      
2005-05-18 10:05:49 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/segment.h      
2005-05-18 10:05:49 -04:00
@@ -40,7 +40,7 @@
 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
 
 #define IDT_ENTRIES 256
-#define GDT_ENTRIES (LAST_RESERVED_GDT_ENTRY + 1)
+#define GDT_ENTRIES 16
 #define GDT_SIZE (GDT_ENTRIES * 8)
 #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) 
 
diff -Nru a/netbsd-2.0-xen-sparse/sys/arch/xen/i386/machdep.c 
b/netbsd-2.0-xen-sparse/sys/arch/xen/i386/machdep.c
--- a/netbsd-2.0-xen-sparse/sys/arch/xen/i386/machdep.c 2005-05-18 10:05:51 
-04:00
+++ b/netbsd-2.0-xen-sparse/sys/arch/xen/i386/machdep.c 2005-05-18 10:05:52 
-04:00
@@ -1430,8 +1430,8 @@
        pmap_kenter_pa((vaddr_t)gdt, (uint32_t)gdt - KERNBASE,
            VM_PROT_READ);
        XENPRINTK(("loading gdt %lx, %d entries\n", frames[0] << PAGE_SHIFT,
-           LAST_RESERVED_GDT_ENTRY + 1));
-       if (HYPERVISOR_set_gdt(frames, LAST_RESERVED_GDT_ENTRY + 1))
+           NGDT);
+       if (HYPERVISOR_set_gdt(frames, NGDT))
                panic("HYPERVISOR_set_gdt failed!\n");
        lgdt_finish();
 #endif
diff -Nru a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    2005-05-18 10:05:51 -04:00
+++ b/tools/libxc/xc_linux_restore.c    2005-05-18 10:05:51 -04:00
@@ -535,13 +535,6 @@
         ctxt.gdt_frames[i] = pfn_to_mfn_table[pfn];
     }
 
-    /* Zero hypervisor GDT entries (supresses ugly warning) */
-    p_gdt = xc_map_foreign_range(
-        xc_handle, dom, PAGE_SIZE, PROT_WRITE, ctxt.gdt_frames[0]);
-    memset( p_gdt + FIRST_RESERVED_GDT_ENTRY*8, 0,
-               NR_RESERVED_GDT_ENTRIES*8 );
-    munmap( p_gdt, PAGE_SIZE );
-
     /* Uncanonicalise the page table base pointer. */
     pfn = ctxt.pt_base >> PAGE_SHIFT;
     if ( (pfn >= nr_pfns) || ((pfn_type[pfn]&LTABTYPE_MASK) != L2TAB) )
diff -Nru a/xen/arch/x86/boot/x86_32.S b/xen/arch/x86/boot/x86_32.S
--- a/xen/arch/x86/boot/x86_32.S        2005-05-18 10:05:49 -04:00
+++ b/xen/arch/x86/boot/x86_32.S        2005-05-18 10:05:49 -04:00
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <public/xen.h>
+#include <asm/desc.h>
 #include <asm/page.h>
 
 #define  SECONDARY_CPU_FLAG 0xA5A5A5A5
@@ -181,40 +182,39 @@
         
         .word   0    
 idt_descr:
-       .word   256*8-1
+        .word  256*8-1
 idt:
         .long  idt_table
 
         .word   0
 gdt_descr:
-       .word   (LAST_RESERVED_GDT_ENTRY*8)+7
-gdt:       
-        .long   gdt_table      /* gdt base */
+        .word  LAST_RESERVED_GDT_BYTE
+gdt:
+        .long   gdt_table - FIRST_RESERVED_GDT_BYTE
 
         .word   0
 nopaging_gdt_descr:
-        .word   (LAST_RESERVED_GDT_ENTRY*8)+7
-        .long   gdt_table-__PAGE_OFFSET
+        .word  LAST_RESERVED_GDT_BYTE
+        .long   gdt_table - FIRST_RESERVED_GDT_BYTE - __PAGE_OFFSET
         
-        ALIGN
+        .org 0x1000
 /* NB. Rings != 0 get access up to 0xFC400000. This allows access to the */
 /*     machine->physical mapping table. Ring 0 can access all memory.    */
 ENTRY(gdt_table)
-        .fill FIRST_RESERVED_GDT_ENTRY,8,0
         .quad 0x0000000000000000     /* unused */
-        .quad 0x00cf9a000000ffff     /* 0x0808 ring 0 4.00GB code at 0x0 */
-        .quad 0x00cf92000000ffff     /* 0x0810 ring 0 4.00GB data at 0x0 */
-        .quad 0x00cfba000000c3ff     /* 0x0819 ring 1 3.95GB code at 0x0 */
-        .quad 0x00cfb2000000c3ff     /* 0x0821 ring 1 3.95GB data at 0x0 */
-        .quad 0x00cffa000000c3ff     /* 0x082b ring 3 3.95GB code at 0x0 */
-        .quad 0x00cff2000000c3ff     /* 0x0833 ring 3 3.95GB data at 0x0 */
+        .quad 0x00cf9a000000ffff     /* 0xe008 ring 0 4.00GB code at 0x0 */
+        .quad 0x00cf92000000ffff     /* 0xe010 ring 0 4.00GB data at 0x0 */
+        .quad 0x00cfba000000c3ff     /* 0xe019 ring 1 3.95GB code at 0x0 */
+        .quad 0x00cfb2000000c3ff     /* 0xe021 ring 1 3.95GB data at 0x0 */
+        .quad 0x00cffa000000c3ff     /* 0xe02b ring 3 3.95GB code at 0x0 */
+        .quad 0x00cff2000000c3ff     /* 0xe033 ring 3 3.95GB data at 0x0 */
         .quad 0x0000000000000000     /* unused                           */
         .fill 2*NR_CPUS,8,0          /* space for TSS and LDT per CPU    */
 
-        .org 0x1000
-ENTRY(idle_pg_table) # Initial page directory is 4kB
         .org 0x2000
+ENTRY(idle_pg_table) # Initial page directory is 4kB
+        .org 0x3000
 ENTRY(cpu0_stack)
-        .org 0x2000 + STACK_SIZE
+        .org 0x3000 + STACK_SIZE
 ENTRY(stext)
 ENTRY(_stext)
diff -Nru a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
--- a/xen/arch/x86/boot/x86_64.S        2005-05-18 10:05:49 -04:00
+++ b/xen/arch/x86/boot/x86_64.S        2005-05-18 10:05:49 -04:00
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <public/xen.h>
+#include <asm/desc.h>
 #include <asm/page.h>
 #include <asm/msr.h>
 
@@ -51,7 +52,7 @@
         cli
 
         /* Set up a few descriptors: on entry only CS is guaranteed good. */
-        lgdt    %cs:0x1001f0
+        lgdt    %cs:0x100400
         mov     $(__HYPERVISOR_DS32),%ecx
         mov     %ecx,%ds
         mov     %ecx,%es
@@ -64,7 +65,7 @@
         jne     not_multiboot
         
         /* Save the Multiboot info structure for later use. */
-        mov     %ebx,0x1001e0
+        mov     %ebx,0x100300
 
         /* We begin by interrogating the CPU for the presence of long mode. */
         mov     $0x80000000,%eax
@@ -167,44 +168,40 @@
         loop    1b
 
         /* Pass off the Multiboot info structure to C land. */
-        mov     0x1001e0,%edi
+        mov     0x100300,%edi
         lea     start(%rip),%rax
         sub     $0x100000,%rax
         add     %rax,%rdi
         call    __start_xen
         ud2     /* Force a panic (invalid opcode). */
 
+/* This is the default interrupt handler. */
+int_msg:
+        .asciz "Unknown interrupt\n"
+ignore_int:
+        cld
+        leaq    int_msg(%rip),%rdi
+        call    printf
+1:      jmp     1b
+
         .code32
 
-        .org    0x1e0
+        .org    0x300
                         
 /*** DESCRIPTOR TABLES ***/
 
 .globl idt
-.globl gdt        
+.globl gdt
 
-        .org    0x1f0
-        .word   (LAST_RESERVED_GDT_ENTRY*8)+7
-        .long   0x100200 # gdt_table
+        .org    0x400
+        .word   LAST_RESERVED_GDT_BYTE
+        .long   0x101000 - FIRST_RESERVED_GDT_BYTE
         
-        .org    0x200
-ENTRY(gdt_table)
-        .fill FIRST_RESERVED_GDT_ENTRY,8,0
-        .quad 0x0000000000000000     /* unused */
-        .quad 0x00cf9a000000ffff     /* 0x0808 ring 0 code, compatibility */
-        .quad 0x00af9a000000ffff     /* 0x0810 ring 0 code, 64-bit mode   */
-        .quad 0x00cf92000000ffff     /* 0x0818 ring 0 data                */
-        .quad 0x00cffa000000ffff     /* 0x0823 ring 3 code, compatibility */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.