diff options
author | Jes Sorensen <jes@sgi.com> | 2007-10-21 21:03:28 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-23 01:49:51 -0400 |
commit | 625efab1cd3d4da4634dfe26df6b4005385397e2 (patch) | |
tree | e08cd714edece430ae8a8aef894adfadbccc064a /drivers/lguest/segments.c | |
parent | 56adbe9ddc935600c64635d6a55c260a63c67e4a (diff) |
Move i386 part of core.c to x86/core.c.
Separate i386 architecture specific from core.c and move it to
x86/core.c and add x86/lguest.h header file to match.
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest/segments.c')
-rw-r--r-- | drivers/lguest/segments.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c index 9b81119f46e9..95eb9cf297bf 100644 --- a/drivers/lguest/segments.c +++ b/drivers/lguest/segments.c | |||
@@ -73,14 +73,14 @@ static void fixup_gdt_table(struct lguest *lg, unsigned start, unsigned end) | |||
73 | /* Segment descriptors contain a privilege level: the Guest is | 73 | /* Segment descriptors contain a privilege level: the Guest is |
74 | * sometimes careless and leaves this as 0, even though it's | 74 | * sometimes careless and leaves this as 0, even though it's |
75 | * running at privilege level 1. If so, we fix it here. */ | 75 | * running at privilege level 1. If so, we fix it here. */ |
76 | if ((lg->gdt[i].b & 0x00006000) == 0) | 76 | if ((lg->arch.gdt[i].b & 0x00006000) == 0) |
77 | lg->gdt[i].b |= (GUEST_PL << 13); | 77 | lg->arch.gdt[i].b |= (GUEST_PL << 13); |
78 | 78 | ||
79 | /* Each descriptor has an "accessed" bit. If we don't set it | 79 | /* Each descriptor has an "accessed" bit. If we don't set it |
80 | * now, the CPU will try to set it when the Guest first loads | 80 | * now, the CPU will try to set it when the Guest first loads |
81 | * that entry into a segment register. But the GDT isn't | 81 | * that entry into a segment register. But the GDT isn't |
82 | * writable by the Guest, so bad things can happen. */ | 82 | * writable by the Guest, so bad things can happen. */ |
83 | lg->gdt[i].b |= 0x00000100; | 83 | lg->arch.gdt[i].b |= 0x00000100; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
@@ -106,12 +106,12 @@ void setup_default_gdt_entries(struct lguest_ro_state *state) | |||
106 | void setup_guest_gdt(struct lguest *lg) | 106 | void setup_guest_gdt(struct lguest *lg) |
107 | { | 107 | { |
108 | /* Start with full 0-4G segments... */ | 108 | /* Start with full 0-4G segments... */ |
109 | lg->gdt[GDT_ENTRY_KERNEL_CS] = FULL_EXEC_SEGMENT; | 109 | lg->arch.gdt[GDT_ENTRY_KERNEL_CS] = FULL_EXEC_SEGMENT; |
110 | lg->gdt[GDT_ENTRY_KERNEL_DS] = FULL_SEGMENT; | 110 | lg->arch.gdt[GDT_ENTRY_KERNEL_DS] = FULL_SEGMENT; |
111 | /* ...except the Guest is allowed to use them, so set the privilege | 111 | /* ...except the Guest is allowed to use them, so set the privilege |
112 | * level appropriately in the flags. */ | 112 | * level appropriately in the flags. */ |
113 | lg->gdt[GDT_ENTRY_KERNEL_CS].b |= (GUEST_PL << 13); | 113 | lg->arch.gdt[GDT_ENTRY_KERNEL_CS].b |= (GUEST_PL << 13); |
114 | lg->gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13); | 114 | lg->arch.gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13); |
115 | } | 115 | } |
116 | 116 | ||
117 | /* Like the IDT, we never simply use the GDT the Guest gives us. We set up the | 117 | /* Like the IDT, we never simply use the GDT the Guest gives us. We set up the |
@@ -126,7 +126,7 @@ void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) | |||
126 | unsigned int i; | 126 | unsigned int i; |
127 | 127 | ||
128 | for (i = GDT_ENTRY_TLS_MIN; i <= GDT_ENTRY_TLS_MAX; i++) | 128 | for (i = GDT_ENTRY_TLS_MIN; i <= GDT_ENTRY_TLS_MAX; i++) |
129 | gdt[i] = lg->gdt[i]; | 129 | gdt[i] = lg->arch.gdt[i]; |
130 | } | 130 | } |
131 | 131 | ||
132 | /* This is the full version */ | 132 | /* This is the full version */ |
@@ -138,7 +138,7 @@ void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) | |||
138 | * replaced. See ignored_gdt() above. */ | 138 | * replaced. See ignored_gdt() above. */ |
139 | for (i = 0; i < GDT_ENTRIES; i++) | 139 | for (i = 0; i < GDT_ENTRIES; i++) |
140 | if (!ignored_gdt(i)) | 140 | if (!ignored_gdt(i)) |
141 | gdt[i] = lg->gdt[i]; | 141 | gdt[i] = lg->arch.gdt[i]; |
142 | } | 142 | } |
143 | 143 | ||
144 | /* This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). */ | 144 | /* This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). */ |
@@ -146,12 +146,12 @@ void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) | |||
146 | { | 146 | { |
147 | /* We assume the Guest has the same number of GDT entries as the | 147 | /* We assume the Guest has the same number of GDT entries as the |
148 | * Host, otherwise we'd have to dynamically allocate the Guest GDT. */ | 148 | * Host, otherwise we'd have to dynamically allocate the Guest GDT. */ |
149 | if (num > ARRAY_SIZE(lg->gdt)) | 149 | if (num > ARRAY_SIZE(lg->arch.gdt)) |
150 | kill_guest(lg, "too many gdt entries %i", num); | 150 | kill_guest(lg, "too many gdt entries %i", num); |
151 | 151 | ||
152 | /* We read the whole thing in, then fix it up. */ | 152 | /* We read the whole thing in, then fix it up. */ |
153 | lgread(lg, lg->gdt, table, num * sizeof(lg->gdt[0])); | 153 | lgread(lg, lg->arch.gdt, table, num * sizeof(lg->arch.gdt[0])); |
154 | fixup_gdt_table(lg, 0, ARRAY_SIZE(lg->gdt)); | 154 | fixup_gdt_table(lg, 0, ARRAY_SIZE(lg->arch.gdt)); |
155 | /* Mark that the GDT changed so the core knows it has to copy it again, | 155 | /* Mark that the GDT changed so the core knows it has to copy it again, |
156 | * even if the Guest is run on the same CPU. */ | 156 | * even if the Guest is run on the same CPU. */ |
157 | lg->changed |= CHANGED_GDT; | 157 | lg->changed |= CHANGED_GDT; |
@@ -159,7 +159,7 @@ void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) | |||
159 | 159 | ||
160 | void guest_load_tls(struct lguest *lg, unsigned long gtls) | 160 | void guest_load_tls(struct lguest *lg, unsigned long gtls) |
161 | { | 161 | { |
162 | struct desc_struct *tls = &lg->gdt[GDT_ENTRY_TLS_MIN]; | 162 | struct desc_struct *tls = &lg->arch.gdt[GDT_ENTRY_TLS_MIN]; |
163 | 163 | ||
164 | lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); | 164 | lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); |
165 | fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); | 165 | fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); |