ia64/xen-unstable

view xen-2.4.16/arch/i386/mm.c @ 86:4a10fe9b20ec

bitkeeper revision 1.15 (3e24a984iRiWWcgfKCxu2p5q3YbxXw)

Many files:
First half of support for per-domain GDTs and LDTs
author kaf24@labyrinth.cl.cam.ac.uk
date Wed Jan 15 00:21:24 2003 +0000 (2003-01-15)
parents c3e6a52cd801
children f72ea5eac57b d59292c8dcab
line source
1 #include <xeno/config.h>
2 #include <xeno/lib.h>
3 #include <xeno/init.h>
4 #include <xeno/mm.h>
5 #include <asm/page.h>
6 #include <asm/pgalloc.h>
7 #include <asm/fixmap.h>
9 static inline void set_pte_phys (unsigned long vaddr,
10 l1_pgentry_t entry)
11 {
12 l2_pgentry_t *l2ent;
13 l1_pgentry_t *l1ent;
15 l2ent = idle0_pg_table + l2_table_offset(vaddr);
16 l1ent = l2_pgentry_to_l1(*l2ent) + l1_table_offset(vaddr);
17 *l1ent = entry;
19 /* It's enough to flush this one mapping. */
20 __flush_tlb_one(vaddr);
21 }
23 void __set_fixmap (enum fixed_addresses idx,
24 l1_pgentry_t entry)
25 {
26 unsigned long address = __fix_to_virt(idx);
28 if (idx >= __end_of_fixed_addresses) {
29 printk("Invalid __set_fixmap\n");
30 return;
31 }
32 set_pte_phys(address, entry);
33 }
35 static void __init fixrange_init (unsigned long start,
36 unsigned long end, l2_pgentry_t *pg_base)
37 {
38 l2_pgentry_t *l2e;
39 int i;
40 unsigned long vaddr, page;
42 vaddr = start;
43 i = l2_table_offset(vaddr);
44 l2e = pg_base + i;
46 for ( ; (i < ENTRIES_PER_L2_PAGETABLE) && (vaddr != end); l2e++, i++ )
47 {
48 if ( !l2_pgentry_empty(*l2e) ) continue;
49 page = (unsigned long)get_free_page(GFP_KERNEL);
50 clear_page(page);
51 *l2e = mk_l2_pgentry(__pa(page) | PAGE_HYPERVISOR);
52 vaddr += 1 << L2_PAGETABLE_SHIFT;
53 }
54 }
56 void __init paging_init(void)
57 {
58 unsigned long addr;
59 void *ioremap_pt;
61 /* XXX initialised in boot.S */
62 /*if ( cpu_has_pge ) set_in_cr4(X86_CR4_PGE);*/
63 /*if ( cpu_has_pse ) set_in_cr4(X86_CR4_PSE);*/
64 /*if ( cpu_has_pae ) set_in_cr4(X86_CR4_PAE);*/
66 /*
67 * Fixed mappings, only the page table structure has to be
68 * created - mappings will be set by set_fixmap():
69 */
70 addr = FIXADDR_START & ~((1<<L2_PAGETABLE_SHIFT)-1);
71 fixrange_init(addr, 0, idle0_pg_table);
73 /* Create page table for ioremap(). */
74 ioremap_pt = (void *)get_free_page(GFP_KERNEL);
75 clear_page(ioremap_pt);
76 idle0_pg_table[MAPCACHE_VIRT_START >> L2_PAGETABLE_SHIFT] =
77 mk_l2_pgentry(__pa(ioremap_pt) | PAGE_HYPERVISOR);
78 }
80 void __init zap_low_mappings (void)
81 {
82 int i, j;
83 for ( i = 0; i < smp_num_cpus; i++ )
84 {
85 for ( j = 0; j < DOMAIN_ENTRIES_PER_L2_PAGETABLE; j++ )
86 {
87 idle_pg_table[i][j] = mk_l2_pgentry(0);
88 }
89 }
90 flush_tlb_all();
91 }
94 long do_stack_and_ldt_switch(
95 unsigned long ss, unsigned long esp, unsigned long ldts)
96 {
97 int nr = smp_processor_id();
98 struct tss_struct *t = &init_tss[nr];
100 if ( (ss == __HYPERVISOR_CS) || (ss == __HYPERVISOR_DS) )
101 return -1;
103 if ( ldts != current->mm.ldt_sel )
104 {
105 unsigned long *ptabent = GET_GDT_ADDRESS(current);
106 /* Out of range for GDT table? */
107 if ( (ldts * 8) > GET_GDT_ENTRIES(current) ) return -1;
108 ptabent += ldts * 2; /* 8 bytes per desc == 2 * unsigned long */
109 /* Not an LDT entry? (S=0b, type =0010b) */
110 if ( (*ptabent & 0x00001f00) != 0x00000200 ) return -1;
111 current->mm.ldt_sel = ldts;
112 __load_LDT(ldts);
113 }
115 current->thread.ss1 = ss;
116 current->thread.esp1 = esp;
117 t->ss1 = ss;
118 t->esp1 = esp;
120 return 0;
121 }
124 long do_set_gdt(unsigned long *frame_list, int entries)
125 {
126 return -ENOSYS;
127 }
130 long do_update_descriptor(
131 unsigned long pa, unsigned long word1, unsigned long word2)
132 {
133 return -ENOSYS;
134 }