blob: c8726c424b3549a2b45aaa839dc21a3d464769ba [file] [log] [blame]
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +01001/*
2 * VMI specific paravirt-ops implementation
3 *
4 * Copyright (C) 2005, VMware, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * Send feedback to zach@vmware.com
22 *
23 */
24
25#include <linux/module.h>
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010026#include <linux/cpu.h>
27#include <linux/bootmem.h>
28#include <linux/mm.h>
Zachary Amsdeneeef9c62007-05-02 19:27:16 +020029#include <linux/highmem.h>
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010030#include <asm/vmi.h>
31#include <asm/io.h>
32#include <asm/fixmap.h>
33#include <asm/apicdef.h>
34#include <asm/apic.h>
35#include <asm/processor.h>
36#include <asm/timer.h>
Zachary Amsdenbbab4f32007-02-13 13:26:21 +010037#include <asm/vmi_time.h>
Adrian Bunk8f485612007-03-05 00:30:56 -080038#include <asm/kmap_types.h>
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010039
40/* Convenient for calling VMI functions indirectly in the ROM */
41typedef u32 __attribute__((regparm(1))) (VROMFUNC)(void);
42typedef u64 __attribute__((regparm(2))) (VROMLONGFUNC)(int);
43
44#define call_vrom_func(rom,func) \
45 (((VROMFUNC *)(rom->func))())
46
47#define call_vrom_long_func(rom,func,arg) \
48 (((VROMLONGFUNC *)(rom->func)) (arg))
49
50static struct vrom_header *vmi_rom;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010051static int disable_pge;
52static int disable_pse;
53static int disable_sep;
54static int disable_tsc;
55static int disable_mtrr;
Zachary Amsden7507ba32007-03-05 00:30:34 -080056static int disable_noidle;
Zachary Amsden772205f2007-03-05 00:30:41 -080057static int disable_vmi_timer;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010058
59/* Cached VMI operations */
Adrian Bunk30a15282007-05-02 19:27:08 +020060static struct {
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010061 void (*cpuid)(void /* non-c */);
62 void (*_set_ldt)(u32 selector);
63 void (*set_tr)(u32 selector);
64 void (*set_kernel_stack)(u32 selector, u32 esp0);
65 void (*allocate_page)(u32, u32, u32, u32, u32);
66 void (*release_page)(u32, u32);
67 void (*set_pte)(pte_t, pte_t *, unsigned);
68 void (*update_pte)(pte_t *, unsigned);
Zachary Amsdeneeef9c62007-05-02 19:27:16 +020069 void (*set_linear_mapping)(int, void *, u32, u32);
70 void (*_flush_tlb)(int);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010071 void (*set_initial_ap_state)(int, int);
Zachary Amsdenbbab4f32007-02-13 13:26:21 +010072 void (*halt)(void);
Zachary Amsden49f19712007-04-08 16:04:01 -070073 void (*set_lazy_mode)(int mode);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010074} vmi_ops;
75
Zachary Amsdene0bb8642007-05-02 19:27:16 +020076/* Cached VMI operations */
77struct vmi_timer_ops vmi_timer_ops;
78
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010079/*
80 * VMI patching routines.
81 */
82#define MNEM_CALL 0xe8
83#define MNEM_JMP 0xe9
84#define MNEM_RET 0xc3
85
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010086#define IRQ_PATCH_INT_MASK 0
87#define IRQ_PATCH_DISABLE 5
88
89static inline void patch_offset(unsigned char *eip, unsigned char *dest)
90{
91 *(unsigned long *)(eip+1) = dest-eip-5;
92}
93
94static unsigned patch_internal(int call, unsigned len, void *insns)
95{
96 u64 reloc;
97 struct vmi_relocation_info *const rel = (struct vmi_relocation_info *)&reloc;
98 reloc = call_vrom_long_func(vmi_rom, get_reloc, call);
99 switch(rel->type) {
100 case VMI_RELOCATION_CALL_REL:
101 BUG_ON(len < 5);
102 *(char *)insns = MNEM_CALL;
103 patch_offset(insns, rel->eip);
104 return 5;
105
106 case VMI_RELOCATION_JUMP_REL:
107 BUG_ON(len < 5);
108 *(char *)insns = MNEM_JMP;
109 patch_offset(insns, rel->eip);
110 return 5;
111
112 case VMI_RELOCATION_NOP:
113 /* obliterate the whole thing */
114 return 0;
115
116 case VMI_RELOCATION_NONE:
117 /* leave native code in place */
118 break;
119
120 default:
121 BUG();
122 }
123 return len;
124}
125
126/*
127 * Apply patch if appropriate, return length of new instruction
128 * sequence. The callee does nop padding for us.
129 */
130static unsigned vmi_patch(u8 type, u16 clobbers, void *insns, unsigned len)
131{
132 switch (type) {
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200133 case PARAVIRT_PATCH(irq_disable):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100134 return patch_internal(VMI_CALL_DisableInterrupts, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200135 case PARAVIRT_PATCH(irq_enable):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100136 return patch_internal(VMI_CALL_EnableInterrupts, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200137 case PARAVIRT_PATCH(restore_fl):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100138 return patch_internal(VMI_CALL_SetInterruptMask, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200139 case PARAVIRT_PATCH(save_fl):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100140 return patch_internal(VMI_CALL_GetInterruptMask, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200141 case PARAVIRT_PATCH(iret):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100142 return patch_internal(VMI_CALL_IRET, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200143 case PARAVIRT_PATCH(irq_enable_sysexit):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100144 return patch_internal(VMI_CALL_SYSEXIT, len, insns);
145 default:
146 break;
147 }
148 return len;
149}
150
151/* CPUID has non-C semantics, and paravirt-ops API doesn't match hardware ISA */
152static void vmi_cpuid(unsigned int *eax, unsigned int *ebx,
153 unsigned int *ecx, unsigned int *edx)
154{
155 int override = 0;
156 if (*eax == 1)
157 override = 1;
158 asm volatile ("call *%6"
159 : "=a" (*eax),
160 "=b" (*ebx),
161 "=c" (*ecx),
162 "=d" (*edx)
163 : "0" (*eax), "2" (*ecx), "r" (vmi_ops.cpuid));
164 if (override) {
165 if (disable_pse)
166 *edx &= ~X86_FEATURE_PSE;
167 if (disable_pge)
168 *edx &= ~X86_FEATURE_PGE;
169 if (disable_sep)
170 *edx &= ~X86_FEATURE_SEP;
171 if (disable_tsc)
172 *edx &= ~X86_FEATURE_TSC;
173 if (disable_mtrr)
174 *edx &= ~X86_FEATURE_MTRR;
175 }
176}
177
178static inline void vmi_maybe_load_tls(struct desc_struct *gdt, int nr, struct desc_struct *new)
179{
180 if (gdt[nr].a != new->a || gdt[nr].b != new->b)
181 write_gdt_entry(gdt, nr, new->a, new->b);
182}
183
184static void vmi_load_tls(struct thread_struct *t, unsigned int cpu)
185{
186 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
187 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 0, &t->tls_array[0]);
188 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 1, &t->tls_array[1]);
189 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 2, &t->tls_array[2]);
190}
191
192static void vmi_set_ldt(const void *addr, unsigned entries)
193{
194 unsigned cpu = smp_processor_id();
195 u32 low, high;
196
197 pack_descriptor(&low, &high, (unsigned long)addr,
198 entries * sizeof(struct desc_struct) - 1,
199 DESCTYPE_LDT, 0);
200 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, low, high);
201 vmi_ops._set_ldt(entries ? GDT_ENTRY_LDT*sizeof(struct desc_struct) : 0);
202}
203
204static void vmi_set_tr(void)
205{
206 vmi_ops.set_tr(GDT_ENTRY_TSS*sizeof(struct desc_struct));
207}
208
209static void vmi_load_esp0(struct tss_struct *tss,
210 struct thread_struct *thread)
211{
Rusty Russella75c54f2007-05-02 19:27:13 +0200212 tss->x86_tss.esp0 = thread->esp0;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100213
214 /* This can only happen when SEP is enabled, no need to test "SEP"arately */
Rusty Russella75c54f2007-05-02 19:27:13 +0200215 if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
216 tss->x86_tss.ss1 = thread->sysenter_cs;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100217 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
218 }
Rusty Russella75c54f2007-05-02 19:27:13 +0200219 vmi_ops.set_kernel_stack(__KERNEL_DS, tss->x86_tss.esp0);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100220}
221
222static void vmi_flush_tlb_user(void)
223{
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200224 vmi_ops._flush_tlb(VMI_FLUSH_TLB);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100225}
226
227static void vmi_flush_tlb_kernel(void)
228{
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200229 vmi_ops._flush_tlb(VMI_FLUSH_TLB | VMI_FLUSH_GLOBAL);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100230}
231
232/* Stub to do nothing at all; used for delays and unimplemented calls */
233static void vmi_nop(void)
234{
235}
236
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100237#ifdef CONFIG_DEBUG_PAGE_TYPE
238
239#ifdef CONFIG_X86_PAE
240#define MAX_BOOT_PTS (2048+4+1)
241#else
242#define MAX_BOOT_PTS (1024+1)
243#endif
244
245/*
246 * During boot, mem_map is not yet available in paging_init, so stash
247 * all the boot page allocations here.
248 */
249static struct {
250 u32 pfn;
251 int type;
252} boot_page_allocations[MAX_BOOT_PTS];
253static int num_boot_page_allocations;
254static int boot_allocations_applied;
255
256void vmi_apply_boot_page_allocations(void)
257{
258 int i;
259 BUG_ON(!mem_map);
260 for (i = 0; i < num_boot_page_allocations; i++) {
261 struct page *page = pfn_to_page(boot_page_allocations[i].pfn);
262 page->type = boot_page_allocations[i].type;
263 page->type = boot_page_allocations[i].type &
264 ~(VMI_PAGE_ZEROED | VMI_PAGE_CLONE);
265 }
266 boot_allocations_applied = 1;
267}
268
269static void record_page_type(u32 pfn, int type)
270{
271 BUG_ON(num_boot_page_allocations >= MAX_BOOT_PTS);
272 boot_page_allocations[num_boot_page_allocations].pfn = pfn;
273 boot_page_allocations[num_boot_page_allocations].type = type;
274 num_boot_page_allocations++;
275}
276
277static void check_zeroed_page(u32 pfn, int type, struct page *page)
278{
279 u32 *ptr;
280 int i;
281 int limit = PAGE_SIZE / sizeof(int);
282
283 if (page_address(page))
284 ptr = (u32 *)page_address(page);
285 else
286 ptr = (u32 *)__va(pfn << PAGE_SHIFT);
287 /*
288 * When cloning the root in non-PAE mode, only the userspace
289 * pdes need to be zeroed.
290 */
291 if (type & VMI_PAGE_CLONE)
292 limit = USER_PTRS_PER_PGD;
293 for (i = 0; i < limit; i++)
294 BUG_ON(ptr[i]);
295}
296
297/*
298 * We stash the page type into struct page so we can verify the page
299 * types are used properly.
300 */
301static void vmi_set_page_type(u32 pfn, int type)
302{
303 /* PAE can have multiple roots per page - don't track */
304 if (PTRS_PER_PMD > 1 && (type & VMI_PAGE_PDP))
305 return;
306
307 if (boot_allocations_applied) {
308 struct page *page = pfn_to_page(pfn);
309 if (type != VMI_PAGE_NORMAL)
310 BUG_ON(page->type);
311 else
312 BUG_ON(page->type == VMI_PAGE_NORMAL);
313 page->type = type & ~(VMI_PAGE_ZEROED | VMI_PAGE_CLONE);
314 if (type & VMI_PAGE_ZEROED)
315 check_zeroed_page(pfn, type, page);
316 } else {
317 record_page_type(pfn, type);
318 }
319}
320
321static void vmi_check_page_type(u32 pfn, int type)
322{
323 /* PAE can have multiple roots per page - skip checks */
324 if (PTRS_PER_PMD > 1 && (type & VMI_PAGE_PDP))
325 return;
326
327 type &= ~(VMI_PAGE_ZEROED | VMI_PAGE_CLONE);
328 if (boot_allocations_applied) {
329 struct page *page = pfn_to_page(pfn);
330 BUG_ON((page->type ^ type) & VMI_PAGE_PAE);
331 BUG_ON(type == VMI_PAGE_NORMAL && page->type);
332 BUG_ON((type & page->type) == 0);
333 }
334}
335#else
336#define vmi_set_page_type(p,t) do { } while (0)
337#define vmi_check_page_type(p,t) do { } while (0)
338#endif
339
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200340#ifdef CONFIG_HIGHPTE
341static void *vmi_kmap_atomic_pte(struct page *page, enum km_type type)
Zachary Amsden9a1c13e2007-03-05 00:30:37 -0800342{
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200343 void *va = kmap_atomic(page, type);
344
Zachary Amsden9a1c13e2007-03-05 00:30:37 -0800345 /*
346 * Internally, the VMI ROM must map virtual addresses to physical
347 * addresses for processing MMU updates. By the time MMU updates
348 * are issued, this information is typically already lost.
349 * Fortunately, the VMI provides a cache of mapping slots for active
350 * page tables.
351 *
352 * We use slot zero for the linear mapping of physical memory, and
353 * in HIGHPTE kernels, slot 1 and 2 for KM_PTE0 and KM_PTE1.
354 *
355 * args: SLOT VA COUNT PFN
356 */
357 BUG_ON(type != KM_PTE0 && type != KM_PTE1);
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200358 vmi_ops.set_linear_mapping((type - KM_PTE0)+1, va, 1, page_to_pfn(page));
359
360 return va;
Zachary Amsden9a1c13e2007-03-05 00:30:37 -0800361}
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200362#endif
Zachary Amsden9a1c13e2007-03-05 00:30:37 -0800363
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100364static void vmi_allocate_pt(u32 pfn)
365{
366 vmi_set_page_type(pfn, VMI_PAGE_L1);
367 vmi_ops.allocate_page(pfn, VMI_PAGE_L1, 0, 0, 0);
368}
369
370static void vmi_allocate_pd(u32 pfn)
371{
372 /*
373 * This call comes in very early, before mem_map is setup.
374 * It is called only for swapper_pg_dir, which already has
375 * data on it.
376 */
377 vmi_set_page_type(pfn, VMI_PAGE_L2);
378 vmi_ops.allocate_page(pfn, VMI_PAGE_L2, 0, 0, 0);
379}
380
381static void vmi_allocate_pd_clone(u32 pfn, u32 clonepfn, u32 start, u32 count)
382{
383 vmi_set_page_type(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE);
384 vmi_check_page_type(clonepfn, VMI_PAGE_L2);
385 vmi_ops.allocate_page(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE, clonepfn, start, count);
386}
387
388static void vmi_release_pt(u32 pfn)
389{
390 vmi_ops.release_page(pfn, VMI_PAGE_L1);
391 vmi_set_page_type(pfn, VMI_PAGE_NORMAL);
392}
393
394static void vmi_release_pd(u32 pfn)
395{
396 vmi_ops.release_page(pfn, VMI_PAGE_L2);
397 vmi_set_page_type(pfn, VMI_PAGE_NORMAL);
398}
399
400/*
401 * Helper macros for MMU update flags. We can defer updates until a flush
402 * or page invalidation only if the update is to the current address space
403 * (otherwise, there is no flush). We must check against init_mm, since
404 * this could be a kernel update, which usually passes init_mm, although
405 * sometimes this check can be skipped if we know the particular function
406 * is only called on user mode PTEs. We could change the kernel to pass
407 * current->active_mm here, but in particular, I was unsure if changing
408 * mm/highmem.c to do this would still be correct on other architectures.
409 */
410#define is_current_as(mm, mustbeuser) ((mm) == current->active_mm || \
411 (!mustbeuser && (mm) == &init_mm))
412#define vmi_flags_addr(mm, addr, level, user) \
413 ((level) | (is_current_as(mm, user) ? \
414 (VMI_PAGE_CURRENT_AS | ((addr) & VMI_PAGE_VA_MASK)) : 0))
415#define vmi_flags_addr_defer(mm, addr, level, user) \
416 ((level) | (is_current_as(mm, user) ? \
417 (VMI_PAGE_DEFER | VMI_PAGE_CURRENT_AS | ((addr) & VMI_PAGE_VA_MASK)) : 0))
418
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +0200419static void vmi_update_pte(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100420{
421 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
422 vmi_ops.update_pte(ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
423}
424
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +0200425static void vmi_update_pte_defer(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100426{
427 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
428 vmi_ops.update_pte(ptep, vmi_flags_addr_defer(mm, addr, VMI_PAGE_PT, 0));
429}
430
431static void vmi_set_pte(pte_t *ptep, pte_t pte)
432{
433 /* XXX because of set_pmd_pte, this can be called on PT or PD layers */
434 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE | VMI_PAGE_PD);
435 vmi_ops.set_pte(pte, ptep, VMI_PAGE_PT);
436}
437
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +0200438static void vmi_set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100439{
440 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
441 vmi_ops.set_pte(pte, ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
442}
443
444static void vmi_set_pmd(pmd_t *pmdp, pmd_t pmdval)
445{
446#ifdef CONFIG_X86_PAE
447 const pte_t pte = { pmdval.pmd, pmdval.pmd >> 32 };
448 vmi_check_page_type(__pa(pmdp) >> PAGE_SHIFT, VMI_PAGE_PMD);
449#else
450 const pte_t pte = { pmdval.pud.pgd.pgd };
451 vmi_check_page_type(__pa(pmdp) >> PAGE_SHIFT, VMI_PAGE_PGD);
452#endif
453 vmi_ops.set_pte(pte, (pte_t *)pmdp, VMI_PAGE_PD);
454}
455
456#ifdef CONFIG_X86_PAE
457
458static void vmi_set_pte_atomic(pte_t *ptep, pte_t pteval)
459{
460 /*
461 * XXX This is called from set_pmd_pte, but at both PT
462 * and PD layers so the VMI_PAGE_PT flag is wrong. But
463 * it is only called for large page mapping changes,
464 * the Xen backend, doesn't support large pages, and the
465 * ESX backend doesn't depend on the flag.
466 */
467 set_64bit((unsigned long long *)ptep,pte_val(pteval));
468 vmi_ops.update_pte(ptep, VMI_PAGE_PT);
469}
470
471static void vmi_set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
472{
473 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
474 vmi_ops.set_pte(pte, ptep, vmi_flags_addr_defer(mm, addr, VMI_PAGE_PT, 1));
475}
476
477static void vmi_set_pud(pud_t *pudp, pud_t pudval)
478{
479 /* Um, eww */
480 const pte_t pte = { pudval.pgd.pgd, pudval.pgd.pgd >> 32 };
481 vmi_check_page_type(__pa(pudp) >> PAGE_SHIFT, VMI_PAGE_PGD);
482 vmi_ops.set_pte(pte, (pte_t *)pudp, VMI_PAGE_PDP);
483}
484
485static void vmi_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
486{
487 const pte_t pte = { 0 };
488 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
489 vmi_ops.set_pte(pte, ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
490}
491
Adrian Bunk8eb68fa2007-05-02 19:27:09 +0200492static void vmi_pmd_clear(pmd_t *pmd)
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100493{
494 const pte_t pte = { 0 };
495 vmi_check_page_type(__pa(pmd) >> PAGE_SHIFT, VMI_PAGE_PMD);
496 vmi_ops.set_pte(pte, (pte_t *)pmd, VMI_PAGE_PD);
497}
498#endif
499
500#ifdef CONFIG_SMP
Zachary Amsdenc6b36e92007-03-05 00:30:43 -0800501static void __devinit
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100502vmi_startup_ipi_hook(int phys_apicid, unsigned long start_eip,
503 unsigned long start_esp)
504{
Zachary Amsdenc6b36e92007-03-05 00:30:43 -0800505 struct vmi_ap_state ap;
506
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100507 /* Default everything to zero. This is fine for most GPRs. */
508 memset(&ap, 0, sizeof(struct vmi_ap_state));
509
510 ap.gdtr_limit = GDT_SIZE - 1;
511 ap.gdtr_base = (unsigned long) get_cpu_gdt_table(phys_apicid);
512
513 ap.idtr_limit = IDT_ENTRIES * 8 - 1;
514 ap.idtr_base = (unsigned long) idt_table;
515
516 ap.ldtr = 0;
517
518 ap.cs = __KERNEL_CS;
519 ap.eip = (unsigned long) start_eip;
520 ap.ss = __KERNEL_DS;
521 ap.esp = (unsigned long) start_esp;
522
523 ap.ds = __USER_DS;
524 ap.es = __USER_DS;
Jeremy Fitzhardinge7c3576d2007-05-02 19:27:16 +0200525 ap.fs = __KERNEL_PERCPU;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100526 ap.gs = 0;
527
528 ap.eflags = 0;
529
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100530#ifdef CONFIG_X86_PAE
531 /* efer should match BSP efer. */
532 if (cpu_has_nx) {
533 unsigned l, h;
534 rdmsr(MSR_EFER, l, h);
535 ap.efer = (unsigned long long) h << 32 | l;
536 }
537#endif
538
539 ap.cr3 = __pa(swapper_pg_dir);
540 /* Protected mode, paging, AM, WP, NE, MP. */
541 ap.cr0 = 0x80050023;
542 ap.cr4 = mmu_cr4_features;
Zachary Amsdenc6b36e92007-03-05 00:30:43 -0800543 vmi_ops.set_initial_ap_state((u32)&ap, phys_apicid);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100544}
545#endif
546
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200547static void vmi_set_lazy_mode(enum paravirt_lazy_mode mode)
Zachary Amsden49f19712007-04-08 16:04:01 -0700548{
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200549 static DEFINE_PER_CPU(enum paravirt_lazy_mode, lazy_mode);
Zachary Amsden49f19712007-04-08 16:04:01 -0700550
551 if (!vmi_ops.set_lazy_mode)
552 return;
553
554 /* Modes should never nest or overlap */
555 BUG_ON(__get_cpu_var(lazy_mode) && !(mode == PARAVIRT_LAZY_NONE ||
556 mode == PARAVIRT_LAZY_FLUSH));
557
558 if (mode == PARAVIRT_LAZY_FLUSH) {
559 vmi_ops.set_lazy_mode(0);
560 vmi_ops.set_lazy_mode(__get_cpu_var(lazy_mode));
561 } else {
562 vmi_ops.set_lazy_mode(mode);
563 __get_cpu_var(lazy_mode) = mode;
564 }
565}
566
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100567static inline int __init check_vmi_rom(struct vrom_header *rom)
568{
569 struct pci_header *pci;
570 struct pnp_header *pnp;
571 const char *manufacturer = "UNKNOWN";
572 const char *product = "UNKNOWN";
573 const char *license = "unspecified";
574
575 if (rom->rom_signature != 0xaa55)
576 return 0;
577 if (rom->vrom_signature != VMI_SIGNATURE)
578 return 0;
579 if (rom->api_version_maj != VMI_API_REV_MAJOR ||
580 rom->api_version_min+1 < VMI_API_REV_MINOR+1) {
581 printk(KERN_WARNING "VMI: Found mismatched rom version %d.%d\n",
582 rom->api_version_maj,
583 rom->api_version_min);
584 return 0;
585 }
586
587 /*
588 * Relying on the VMI_SIGNATURE field is not 100% safe, so check
589 * the PCI header and device type to make sure this is really a
590 * VMI device.
591 */
592 if (!rom->pci_header_offs) {
593 printk(KERN_WARNING "VMI: ROM does not contain PCI header.\n");
594 return 0;
595 }
596
597 pci = (struct pci_header *)((char *)rom+rom->pci_header_offs);
598 if (pci->vendorID != PCI_VENDOR_ID_VMWARE ||
599 pci->deviceID != PCI_DEVICE_ID_VMWARE_VMI) {
600 /* Allow it to run... anyways, but warn */
601 printk(KERN_WARNING "VMI: ROM from unknown manufacturer\n");
602 }
603
604 if (rom->pnp_header_offs) {
605 pnp = (struct pnp_header *)((char *)rom+rom->pnp_header_offs);
606 if (pnp->manufacturer_offset)
607 manufacturer = (const char *)rom+pnp->manufacturer_offset;
608 if (pnp->product_offset)
609 product = (const char *)rom+pnp->product_offset;
610 }
611
612 if (rom->license_offs)
613 license = (char *)rom+rom->license_offs;
614
615 printk(KERN_INFO "VMI: Found %s %s, API version %d.%d, ROM version %d.%d\n",
616 manufacturer, product,
617 rom->api_version_maj, rom->api_version_min,
618 pci->rom_version_maj, pci->rom_version_min);
619
Andi Kleen302cf932007-03-16 21:07:36 +0100620 /* Don't allow BSD/MIT here for now because we don't want to end up
621 with any binary only shim layers */
622 if (strcmp(license, "GPL") && strcmp(license, "GPL v2")) {
623 printk(KERN_WARNING "VMI: Non GPL license `%s' found for ROM. Not used.\n",
624 license);
625 return 0;
626 }
627
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100628 return 1;
629}
630
631/*
632 * Probe for the VMI option ROM
633 */
634static inline int __init probe_vmi_rom(void)
635{
636 unsigned long base;
637
638 /* VMI ROM is in option ROM area, check signature */
639 for (base = 0xC0000; base < 0xE0000; base += 2048) {
640 struct vrom_header *romstart;
641 romstart = (struct vrom_header *)isa_bus_to_virt(base);
642 if (check_vmi_rom(romstart)) {
643 vmi_rom = romstart;
644 return 1;
645 }
646 }
647 return 0;
648}
649
650/*
651 * VMI setup common to all processors
652 */
653void vmi_bringup(void)
654{
655 /* We must establish the lowmem mapping for MMU ops to work */
Zachary Amsden772205f2007-03-05 00:30:41 -0800656 if (vmi_ops.set_linear_mapping)
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200657 vmi_ops.set_linear_mapping(0, (void *)__PAGE_OFFSET, max_low_pfn, 0);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100658}
659
660/*
Zachary Amsden772205f2007-03-05 00:30:41 -0800661 * Return a pointer to a VMI function or NULL if unimplemented
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100662 */
663static void *vmi_get_function(int vmicall)
664{
665 u64 reloc;
666 const struct vmi_relocation_info *rel = (struct vmi_relocation_info *)&reloc;
667 reloc = call_vrom_long_func(vmi_rom, get_reloc, vmicall);
668 BUG_ON(rel->type == VMI_RELOCATION_JUMP_REL);
669 if (rel->type == VMI_RELOCATION_CALL_REL)
670 return (void *)rel->eip;
671 else
Zachary Amsden772205f2007-03-05 00:30:41 -0800672 return NULL;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100673}
674
675/*
676 * Helper macro for making the VMI paravirt-ops fill code readable.
Zachary Amsden772205f2007-03-05 00:30:41 -0800677 * For unimplemented operations, fall back to default, unless nop
678 * is returned by the ROM.
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100679 */
680#define para_fill(opname, vmicall) \
681do { \
682 reloc = call_vrom_long_func(vmi_rom, get_reloc, \
683 VMI_CALL_##vmicall); \
Zachary Amsden0492c372007-04-12 19:28:46 -0700684 if (rel->type == VMI_RELOCATION_CALL_REL) \
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100685 paravirt_ops.opname = (void *)rel->eip; \
Zachary Amsden0492c372007-04-12 19:28:46 -0700686 else if (rel->type == VMI_RELOCATION_NOP) \
Zachary Amsden772205f2007-03-05 00:30:41 -0800687 paravirt_ops.opname = (void *)vmi_nop; \
Zachary Amsden0492c372007-04-12 19:28:46 -0700688 else if (rel->type != VMI_RELOCATION_NONE) \
689 printk(KERN_WARNING "VMI: Unknown relocation " \
690 "type %d for " #vmicall"\n",\
691 rel->type); \
Zachary Amsden772205f2007-03-05 00:30:41 -0800692} while (0)
693
694/*
695 * Helper macro for making the VMI paravirt-ops fill code readable.
696 * For cached operations which do not match the VMI ROM ABI and must
697 * go through a tranlation stub. Ignore NOPs, since it is not clear
698 * a NOP * VMI function corresponds to a NOP paravirt-op when the
699 * functions are not in 1-1 correspondence.
700 */
701#define para_wrap(opname, wrapper, cache, vmicall) \
702do { \
703 reloc = call_vrom_long_func(vmi_rom, get_reloc, \
704 VMI_CALL_##vmicall); \
705 BUG_ON(rel->type == VMI_RELOCATION_JUMP_REL); \
706 if (rel->type == VMI_RELOCATION_CALL_REL) { \
707 paravirt_ops.opname = wrapper; \
708 vmi_ops.cache = (void *)rel->eip; \
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100709 } \
710} while (0)
711
712/*
713 * Activate the VMI interface and switch into paravirtualized mode
714 */
715static inline int __init activate_vmi(void)
716{
717 short kernel_cs;
718 u64 reloc;
719 const struct vmi_relocation_info *rel = (struct vmi_relocation_info *)&reloc;
720
721 if (call_vrom_func(vmi_rom, vmi_init) != 0) {
722 printk(KERN_ERR "VMI ROM failed to initialize!");
723 return 0;
724 }
725 savesegment(cs, kernel_cs);
726
727 paravirt_ops.paravirt_enabled = 1;
728 paravirt_ops.kernel_rpl = kernel_cs & SEGMENT_RPL_MASK;
729
730 paravirt_ops.patch = vmi_patch;
731 paravirt_ops.name = "vmi";
732
733 /*
734 * Many of these operations are ABI compatible with VMI.
735 * This means we can fill in the paravirt-ops with direct
736 * pointers into the VMI ROM. If the calling convention for
737 * these operations changes, this code needs to be updated.
738 *
739 * Exceptions
740 * CPUID paravirt-op uses pointers, not the native ISA
741 * halt has no VMI equivalent; all VMI halts are "safe"
742 * no MSR support yet - just trap and emulate. VMI uses the
743 * same ABI as the native ISA, but Linux wants exceptions
744 * from bogus MSR read / write handled
745 * rdpmc is not yet used in Linux
746 */
747
Zachary Amsden772205f2007-03-05 00:30:41 -0800748 /* CPUID is special, so very special it gets wrapped like a present */
749 para_wrap(cpuid, vmi_cpuid, cpuid, CPUID);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100750
751 para_fill(clts, CLTS);
752 para_fill(get_debugreg, GetDR);
753 para_fill(set_debugreg, SetDR);
754 para_fill(read_cr0, GetCR0);
755 para_fill(read_cr2, GetCR2);
756 para_fill(read_cr3, GetCR3);
757 para_fill(read_cr4, GetCR4);
758 para_fill(write_cr0, SetCR0);
759 para_fill(write_cr2, SetCR2);
760 para_fill(write_cr3, SetCR3);
761 para_fill(write_cr4, SetCR4);
762 para_fill(save_fl, GetInterruptMask);
763 para_fill(restore_fl, SetInterruptMask);
764 para_fill(irq_disable, DisableInterrupts);
765 para_fill(irq_enable, EnableInterrupts);
Zachary Amsden772205f2007-03-05 00:30:41 -0800766
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100767 para_fill(wbinvd, WBINVD);
Zachary Amsden772205f2007-03-05 00:30:41 -0800768 para_fill(read_tsc, RDTSC);
769
770 /* The following we emulate with trap and emulate for now */
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100771 /* paravirt_ops.read_msr = vmi_rdmsr */
772 /* paravirt_ops.write_msr = vmi_wrmsr */
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100773 /* paravirt_ops.rdpmc = vmi_rdpmc */
774
Zachary Amsden772205f2007-03-05 00:30:41 -0800775 /* TR interface doesn't pass TR value, wrap */
776 para_wrap(load_tr_desc, vmi_set_tr, set_tr, SetTR);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100777
778 /* LDT is special, too */
Zachary Amsden772205f2007-03-05 00:30:41 -0800779 para_wrap(set_ldt, vmi_set_ldt, _set_ldt, SetLDT);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100780
781 para_fill(load_gdt, SetGDT);
782 para_fill(load_idt, SetIDT);
783 para_fill(store_gdt, GetGDT);
784 para_fill(store_idt, GetIDT);
785 para_fill(store_tr, GetTR);
786 paravirt_ops.load_tls = vmi_load_tls;
787 para_fill(write_ldt_entry, WriteLDTEntry);
788 para_fill(write_gdt_entry, WriteGDTEntry);
789 para_fill(write_idt_entry, WriteIDTEntry);
Zachary Amsden772205f2007-03-05 00:30:41 -0800790 para_wrap(load_esp0, vmi_load_esp0, set_kernel_stack, UpdateKernelStack);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100791 para_fill(set_iopl_mask, SetIOPLMask);
Zachary Amsden772205f2007-03-05 00:30:41 -0800792 para_fill(io_delay, IODelay);
Zachary Amsden49f19712007-04-08 16:04:01 -0700793 para_wrap(set_lazy_mode, vmi_set_lazy_mode, set_lazy_mode, SetLazyMode);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100794
Zachary Amsden772205f2007-03-05 00:30:41 -0800795 /* user and kernel flush are just handled with different flags to FlushTLB */
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200796 para_wrap(flush_tlb_user, vmi_flush_tlb_user, _flush_tlb, FlushTLB);
797 para_wrap(flush_tlb_kernel, vmi_flush_tlb_kernel, _flush_tlb, FlushTLB);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100798 para_fill(flush_tlb_single, InvalPage);
799
800 /*
801 * Until a standard flag format can be agreed on, we need to
802 * implement these as wrappers in Linux. Get the VMI ROM
803 * function pointers for the two backend calls.
804 */
805#ifdef CONFIG_X86_PAE
806 vmi_ops.set_pte = vmi_get_function(VMI_CALL_SetPxELong);
807 vmi_ops.update_pte = vmi_get_function(VMI_CALL_UpdatePxELong);
808#else
809 vmi_ops.set_pte = vmi_get_function(VMI_CALL_SetPxE);
810 vmi_ops.update_pte = vmi_get_function(VMI_CALL_UpdatePxE);
811#endif
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100812
Zachary Amsden772205f2007-03-05 00:30:41 -0800813 if (vmi_ops.set_pte) {
814 paravirt_ops.set_pte = vmi_set_pte;
815 paravirt_ops.set_pte_at = vmi_set_pte_at;
816 paravirt_ops.set_pmd = vmi_set_pmd;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100817#ifdef CONFIG_X86_PAE
Zachary Amsden772205f2007-03-05 00:30:41 -0800818 paravirt_ops.set_pte_atomic = vmi_set_pte_atomic;
819 paravirt_ops.set_pte_present = vmi_set_pte_present;
820 paravirt_ops.set_pud = vmi_set_pud;
821 paravirt_ops.pte_clear = vmi_pte_clear;
822 paravirt_ops.pmd_clear = vmi_pmd_clear;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100823#endif
Zachary Amsden772205f2007-03-05 00:30:41 -0800824 }
825
826 if (vmi_ops.update_pte) {
827 paravirt_ops.pte_update = vmi_update_pte;
828 paravirt_ops.pte_update_defer = vmi_update_pte_defer;
829 }
830
831 vmi_ops.allocate_page = vmi_get_function(VMI_CALL_AllocatePage);
832 if (vmi_ops.allocate_page) {
833 paravirt_ops.alloc_pt = vmi_allocate_pt;
834 paravirt_ops.alloc_pd = vmi_allocate_pd;
835 paravirt_ops.alloc_pd_clone = vmi_allocate_pd_clone;
836 }
837
838 vmi_ops.release_page = vmi_get_function(VMI_CALL_ReleasePage);
839 if (vmi_ops.release_page) {
840 paravirt_ops.release_pt = vmi_release_pt;
841 paravirt_ops.release_pd = vmi_release_pd;
842 }
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200843
844 /* Set linear is needed in all cases */
845 vmi_ops.set_linear_mapping = vmi_get_function(VMI_CALL_SetLinearMapping);
846#ifdef CONFIG_HIGHPTE
847 if (vmi_ops.set_linear_mapping)
848 paravirt_ops.kmap_atomic_pte = vmi_kmap_atomic_pte;
Jeremy Fitzhardingea27fe802007-05-02 19:27:15 +0200849#endif
Zachary Amsden772205f2007-03-05 00:30:41 -0800850
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100851 /*
852 * These MUST always be patched. Don't support indirect jumps
853 * through these operations, as the VMI interface may use either
854 * a jump or a call to get to these operations, depending on
855 * the backend. They are performance critical anyway, so requiring
856 * a patch is not a big problem.
857 */
858 paravirt_ops.irq_enable_sysexit = (void *)0xfeedbab0;
859 paravirt_ops.iret = (void *)0xbadbab0;
860
861#ifdef CONFIG_SMP
Zachary Amsden772205f2007-03-05 00:30:41 -0800862 para_wrap(startup_ipi_hook, vmi_startup_ipi_hook, set_initial_ap_state, SetInitialAPState);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100863#endif
864
865#ifdef CONFIG_X86_LOCAL_APIC
Zachary Amsden772205f2007-03-05 00:30:41 -0800866 para_fill(apic_read, APICRead);
867 para_fill(apic_write, APICWrite);
868 para_fill(apic_write_atomic, APICWrite);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100869#endif
870
871 /*
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100872 * Check for VMI timer functionality by probing for a cycle frequency method
873 */
874 reloc = call_vrom_long_func(vmi_rom, get_reloc, VMI_CALL_GetCycleFrequency);
Zachary Amsden772205f2007-03-05 00:30:41 -0800875 if (!disable_vmi_timer && rel->type != VMI_RELOCATION_NONE) {
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100876 vmi_timer_ops.get_cycle_frequency = (void *)rel->eip;
877 vmi_timer_ops.get_cycle_counter =
878 vmi_get_function(VMI_CALL_GetCycleCounter);
879 vmi_timer_ops.get_wallclock =
880 vmi_get_function(VMI_CALL_GetWallclockTime);
881 vmi_timer_ops.wallclock_updated =
882 vmi_get_function(VMI_CALL_WallclockUpdated);
883 vmi_timer_ops.set_alarm = vmi_get_function(VMI_CALL_SetAlarm);
884 vmi_timer_ops.cancel_alarm =
885 vmi_get_function(VMI_CALL_CancelAlarm);
886 paravirt_ops.time_init = vmi_time_init;
887 paravirt_ops.get_wallclock = vmi_get_wallclock;
888 paravirt_ops.set_wallclock = vmi_set_wallclock;
889#ifdef CONFIG_X86_LOCAL_APIC
Zachary Amsdene0bb8642007-05-02 19:27:16 +0200890 paravirt_ops.setup_boot_clock = vmi_time_bsp_init;
891 paravirt_ops.setup_secondary_clock = vmi_time_ap_init;
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100892#endif
Zachary Amsden6cb9a832007-03-05 00:30:35 -0800893 paravirt_ops.get_scheduled_cycles = vmi_get_sched_cycles;
Zachary Amsden1182d852007-03-05 00:30:36 -0800894 paravirt_ops.get_cpu_khz = vmi_cpu_khz;
Zachary Amsden772205f2007-03-05 00:30:41 -0800895
896 /* We have true wallclock functions; disable CMOS clock sync */
897 no_sync_cmos_clock = 1;
898 } else {
899 disable_noidle = 1;
900 disable_vmi_timer = 1;
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100901 }
Zachary Amsden772205f2007-03-05 00:30:41 -0800902
Zachary Amsdene0bb8642007-05-02 19:27:16 +0200903 para_fill(safe_halt, Halt);
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100904
905 /*
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100906 * Alternative instruction rewriting doesn't happen soon enough
907 * to convert VMI_IRET to a call instead of a jump; so we have
908 * to do this before IRQs get reenabled. Fortunately, it is
909 * idempotent.
910 */
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200911 apply_paravirt(__parainstructions, __parainstructions_end);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100912
913 vmi_bringup();
914
915 return 1;
916}
917
918#undef para_fill
919
920void __init vmi_init(void)
921{
922 unsigned long flags;
923
924 if (!vmi_rom)
925 probe_vmi_rom();
926 else
927 check_vmi_rom(vmi_rom);
928
929 /* In case probing for or validating the ROM failed, basil */
930 if (!vmi_rom)
931 return;
932
933 reserve_top_address(-vmi_rom->virtual_top);
934
935 local_irq_save(flags);
936 activate_vmi();
Zachary Amsden7507ba32007-03-05 00:30:34 -0800937
938#ifdef CONFIG_X86_IO_APIC
Zachary Amsden772205f2007-03-05 00:30:41 -0800939 /* This is virtual hardware; timer routing is wired correctly */
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100940 no_timer_check = 1;
941#endif
942 local_irq_restore(flags & X86_EFLAGS_IF);
943}
944
945static int __init parse_vmi(char *arg)
946{
947 if (!arg)
948 return -EINVAL;
949
Zachary Amsdeneda08b12007-03-05 00:30:38 -0800950 if (!strcmp(arg, "disable_pge")) {
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100951 clear_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability);
952 disable_pge = 1;
953 } else if (!strcmp(arg, "disable_pse")) {
954 clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
955 disable_pse = 1;
956 } else if (!strcmp(arg, "disable_sep")) {
957 clear_bit(X86_FEATURE_SEP, boot_cpu_data.x86_capability);
958 disable_sep = 1;
959 } else if (!strcmp(arg, "disable_tsc")) {
960 clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
961 disable_tsc = 1;
962 } else if (!strcmp(arg, "disable_mtrr")) {
963 clear_bit(X86_FEATURE_MTRR, boot_cpu_data.x86_capability);
964 disable_mtrr = 1;
Zachary Amsden772205f2007-03-05 00:30:41 -0800965 } else if (!strcmp(arg, "disable_timer")) {
966 disable_vmi_timer = 1;
967 disable_noidle = 1;
Zachary Amsden7507ba32007-03-05 00:30:34 -0800968 } else if (!strcmp(arg, "disable_noidle"))
969 disable_noidle = 1;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100970 return 0;
971}
972
973early_param("vmi", parse_vmi);