blob: 0fae15dee7650c6336314621521b8fc913d6ed4f [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
76/* XXX move this to alternative.h */
77extern struct paravirt_patch __start_parainstructions[],
78 __stop_parainstructions[];
79
Zachary Amsdene0bb8642007-05-02 19:27:16 +020080/* Cached VMI operations */
81struct vmi_timer_ops vmi_timer_ops;
82
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010083/*
84 * VMI patching routines.
85 */
86#define MNEM_CALL 0xe8
87#define MNEM_JMP 0xe9
88#define MNEM_RET 0xc3
89
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +010090#define IRQ_PATCH_INT_MASK 0
91#define IRQ_PATCH_DISABLE 5
92
93static inline void patch_offset(unsigned char *eip, unsigned char *dest)
94{
95 *(unsigned long *)(eip+1) = dest-eip-5;
96}
97
98static unsigned patch_internal(int call, unsigned len, void *insns)
99{
100 u64 reloc;
101 struct vmi_relocation_info *const rel = (struct vmi_relocation_info *)&reloc;
102 reloc = call_vrom_long_func(vmi_rom, get_reloc, call);
103 switch(rel->type) {
104 case VMI_RELOCATION_CALL_REL:
105 BUG_ON(len < 5);
106 *(char *)insns = MNEM_CALL;
107 patch_offset(insns, rel->eip);
108 return 5;
109
110 case VMI_RELOCATION_JUMP_REL:
111 BUG_ON(len < 5);
112 *(char *)insns = MNEM_JMP;
113 patch_offset(insns, rel->eip);
114 return 5;
115
116 case VMI_RELOCATION_NOP:
117 /* obliterate the whole thing */
118 return 0;
119
120 case VMI_RELOCATION_NONE:
121 /* leave native code in place */
122 break;
123
124 default:
125 BUG();
126 }
127 return len;
128}
129
130/*
131 * Apply patch if appropriate, return length of new instruction
132 * sequence. The callee does nop padding for us.
133 */
134static unsigned vmi_patch(u8 type, u16 clobbers, void *insns, unsigned len)
135{
136 switch (type) {
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200137 case PARAVIRT_PATCH(irq_disable):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100138 return patch_internal(VMI_CALL_DisableInterrupts, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200139 case PARAVIRT_PATCH(irq_enable):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100140 return patch_internal(VMI_CALL_EnableInterrupts, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200141 case PARAVIRT_PATCH(restore_fl):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100142 return patch_internal(VMI_CALL_SetInterruptMask, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200143 case PARAVIRT_PATCH(save_fl):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100144 return patch_internal(VMI_CALL_GetInterruptMask, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200145 case PARAVIRT_PATCH(iret):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100146 return patch_internal(VMI_CALL_IRET, len, insns);
Jeremy Fitzhardinged5822032007-05-02 19:27:14 +0200147 case PARAVIRT_PATCH(irq_enable_sysexit):
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100148 return patch_internal(VMI_CALL_SYSEXIT, len, insns);
149 default:
150 break;
151 }
152 return len;
153}
154
155/* CPUID has non-C semantics, and paravirt-ops API doesn't match hardware ISA */
156static void vmi_cpuid(unsigned int *eax, unsigned int *ebx,
157 unsigned int *ecx, unsigned int *edx)
158{
159 int override = 0;
160 if (*eax == 1)
161 override = 1;
162 asm volatile ("call *%6"
163 : "=a" (*eax),
164 "=b" (*ebx),
165 "=c" (*ecx),
166 "=d" (*edx)
167 : "0" (*eax), "2" (*ecx), "r" (vmi_ops.cpuid));
168 if (override) {
169 if (disable_pse)
170 *edx &= ~X86_FEATURE_PSE;
171 if (disable_pge)
172 *edx &= ~X86_FEATURE_PGE;
173 if (disable_sep)
174 *edx &= ~X86_FEATURE_SEP;
175 if (disable_tsc)
176 *edx &= ~X86_FEATURE_TSC;
177 if (disable_mtrr)
178 *edx &= ~X86_FEATURE_MTRR;
179 }
180}
181
182static inline void vmi_maybe_load_tls(struct desc_struct *gdt, int nr, struct desc_struct *new)
183{
184 if (gdt[nr].a != new->a || gdt[nr].b != new->b)
185 write_gdt_entry(gdt, nr, new->a, new->b);
186}
187
188static void vmi_load_tls(struct thread_struct *t, unsigned int cpu)
189{
190 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
191 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 0, &t->tls_array[0]);
192 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 1, &t->tls_array[1]);
193 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 2, &t->tls_array[2]);
194}
195
196static void vmi_set_ldt(const void *addr, unsigned entries)
197{
198 unsigned cpu = smp_processor_id();
199 u32 low, high;
200
201 pack_descriptor(&low, &high, (unsigned long)addr,
202 entries * sizeof(struct desc_struct) - 1,
203 DESCTYPE_LDT, 0);
204 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, low, high);
205 vmi_ops._set_ldt(entries ? GDT_ENTRY_LDT*sizeof(struct desc_struct) : 0);
206}
207
208static void vmi_set_tr(void)
209{
210 vmi_ops.set_tr(GDT_ENTRY_TSS*sizeof(struct desc_struct));
211}
212
213static void vmi_load_esp0(struct tss_struct *tss,
214 struct thread_struct *thread)
215{
Rusty Russella75c54f2007-05-02 19:27:13 +0200216 tss->x86_tss.esp0 = thread->esp0;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100217
218 /* This can only happen when SEP is enabled, no need to test "SEP"arately */
Rusty Russella75c54f2007-05-02 19:27:13 +0200219 if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
220 tss->x86_tss.ss1 = thread->sysenter_cs;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100221 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
222 }
Rusty Russella75c54f2007-05-02 19:27:13 +0200223 vmi_ops.set_kernel_stack(__KERNEL_DS, tss->x86_tss.esp0);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100224}
225
226static void vmi_flush_tlb_user(void)
227{
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200228 vmi_ops._flush_tlb(VMI_FLUSH_TLB);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100229}
230
231static void vmi_flush_tlb_kernel(void)
232{
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200233 vmi_ops._flush_tlb(VMI_FLUSH_TLB | VMI_FLUSH_GLOBAL);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100234}
235
236/* Stub to do nothing at all; used for delays and unimplemented calls */
237static void vmi_nop(void)
238{
239}
240
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100241#ifdef CONFIG_DEBUG_PAGE_TYPE
242
243#ifdef CONFIG_X86_PAE
244#define MAX_BOOT_PTS (2048+4+1)
245#else
246#define MAX_BOOT_PTS (1024+1)
247#endif
248
249/*
250 * During boot, mem_map is not yet available in paging_init, so stash
251 * all the boot page allocations here.
252 */
253static struct {
254 u32 pfn;
255 int type;
256} boot_page_allocations[MAX_BOOT_PTS];
257static int num_boot_page_allocations;
258static int boot_allocations_applied;
259
260void vmi_apply_boot_page_allocations(void)
261{
262 int i;
263 BUG_ON(!mem_map);
264 for (i = 0; i < num_boot_page_allocations; i++) {
265 struct page *page = pfn_to_page(boot_page_allocations[i].pfn);
266 page->type = boot_page_allocations[i].type;
267 page->type = boot_page_allocations[i].type &
268 ~(VMI_PAGE_ZEROED | VMI_PAGE_CLONE);
269 }
270 boot_allocations_applied = 1;
271}
272
273static void record_page_type(u32 pfn, int type)
274{
275 BUG_ON(num_boot_page_allocations >= MAX_BOOT_PTS);
276 boot_page_allocations[num_boot_page_allocations].pfn = pfn;
277 boot_page_allocations[num_boot_page_allocations].type = type;
278 num_boot_page_allocations++;
279}
280
281static void check_zeroed_page(u32 pfn, int type, struct page *page)
282{
283 u32 *ptr;
284 int i;
285 int limit = PAGE_SIZE / sizeof(int);
286
287 if (page_address(page))
288 ptr = (u32 *)page_address(page);
289 else
290 ptr = (u32 *)__va(pfn << PAGE_SHIFT);
291 /*
292 * When cloning the root in non-PAE mode, only the userspace
293 * pdes need to be zeroed.
294 */
295 if (type & VMI_PAGE_CLONE)
296 limit = USER_PTRS_PER_PGD;
297 for (i = 0; i < limit; i++)
298 BUG_ON(ptr[i]);
299}
300
301/*
302 * We stash the page type into struct page so we can verify the page
303 * types are used properly.
304 */
305static void vmi_set_page_type(u32 pfn, int type)
306{
307 /* PAE can have multiple roots per page - don't track */
308 if (PTRS_PER_PMD > 1 && (type & VMI_PAGE_PDP))
309 return;
310
311 if (boot_allocations_applied) {
312 struct page *page = pfn_to_page(pfn);
313 if (type != VMI_PAGE_NORMAL)
314 BUG_ON(page->type);
315 else
316 BUG_ON(page->type == VMI_PAGE_NORMAL);
317 page->type = type & ~(VMI_PAGE_ZEROED | VMI_PAGE_CLONE);
318 if (type & VMI_PAGE_ZEROED)
319 check_zeroed_page(pfn, type, page);
320 } else {
321 record_page_type(pfn, type);
322 }
323}
324
325static void vmi_check_page_type(u32 pfn, int type)
326{
327 /* PAE can have multiple roots per page - skip checks */
328 if (PTRS_PER_PMD > 1 && (type & VMI_PAGE_PDP))
329 return;
330
331 type &= ~(VMI_PAGE_ZEROED | VMI_PAGE_CLONE);
332 if (boot_allocations_applied) {
333 struct page *page = pfn_to_page(pfn);
334 BUG_ON((page->type ^ type) & VMI_PAGE_PAE);
335 BUG_ON(type == VMI_PAGE_NORMAL && page->type);
336 BUG_ON((type & page->type) == 0);
337 }
338}
339#else
340#define vmi_set_page_type(p,t) do { } while (0)
341#define vmi_check_page_type(p,t) do { } while (0)
342#endif
343
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200344#ifdef CONFIG_HIGHPTE
345static void *vmi_kmap_atomic_pte(struct page *page, enum km_type type)
Zachary Amsden9a1c13e2007-03-05 00:30:37 -0800346{
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200347 void *va = kmap_atomic(page, type);
348
Zachary Amsden9a1c13e2007-03-05 00:30:37 -0800349 /*
350 * Internally, the VMI ROM must map virtual addresses to physical
351 * addresses for processing MMU updates. By the time MMU updates
352 * are issued, this information is typically already lost.
353 * Fortunately, the VMI provides a cache of mapping slots for active
354 * page tables.
355 *
356 * We use slot zero for the linear mapping of physical memory, and
357 * in HIGHPTE kernels, slot 1 and 2 for KM_PTE0 and KM_PTE1.
358 *
359 * args: SLOT VA COUNT PFN
360 */
361 BUG_ON(type != KM_PTE0 && type != KM_PTE1);
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200362 vmi_ops.set_linear_mapping((type - KM_PTE0)+1, va, 1, page_to_pfn(page));
363
364 return va;
Zachary Amsden9a1c13e2007-03-05 00:30:37 -0800365}
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200366#endif
Zachary Amsden9a1c13e2007-03-05 00:30:37 -0800367
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100368static void vmi_allocate_pt(u32 pfn)
369{
370 vmi_set_page_type(pfn, VMI_PAGE_L1);
371 vmi_ops.allocate_page(pfn, VMI_PAGE_L1, 0, 0, 0);
372}
373
374static void vmi_allocate_pd(u32 pfn)
375{
376 /*
377 * This call comes in very early, before mem_map is setup.
378 * It is called only for swapper_pg_dir, which already has
379 * data on it.
380 */
381 vmi_set_page_type(pfn, VMI_PAGE_L2);
382 vmi_ops.allocate_page(pfn, VMI_PAGE_L2, 0, 0, 0);
383}
384
385static void vmi_allocate_pd_clone(u32 pfn, u32 clonepfn, u32 start, u32 count)
386{
387 vmi_set_page_type(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE);
388 vmi_check_page_type(clonepfn, VMI_PAGE_L2);
389 vmi_ops.allocate_page(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE, clonepfn, start, count);
390}
391
392static void vmi_release_pt(u32 pfn)
393{
394 vmi_ops.release_page(pfn, VMI_PAGE_L1);
395 vmi_set_page_type(pfn, VMI_PAGE_NORMAL);
396}
397
398static void vmi_release_pd(u32 pfn)
399{
400 vmi_ops.release_page(pfn, VMI_PAGE_L2);
401 vmi_set_page_type(pfn, VMI_PAGE_NORMAL);
402}
403
404/*
405 * Helper macros for MMU update flags. We can defer updates until a flush
406 * or page invalidation only if the update is to the current address space
407 * (otherwise, there is no flush). We must check against init_mm, since
408 * this could be a kernel update, which usually passes init_mm, although
409 * sometimes this check can be skipped if we know the particular function
410 * is only called on user mode PTEs. We could change the kernel to pass
411 * current->active_mm here, but in particular, I was unsure if changing
412 * mm/highmem.c to do this would still be correct on other architectures.
413 */
414#define is_current_as(mm, mustbeuser) ((mm) == current->active_mm || \
415 (!mustbeuser && (mm) == &init_mm))
416#define vmi_flags_addr(mm, addr, level, user) \
417 ((level) | (is_current_as(mm, user) ? \
418 (VMI_PAGE_CURRENT_AS | ((addr) & VMI_PAGE_VA_MASK)) : 0))
419#define vmi_flags_addr_defer(mm, addr, level, user) \
420 ((level) | (is_current_as(mm, user) ? \
421 (VMI_PAGE_DEFER | VMI_PAGE_CURRENT_AS | ((addr) & VMI_PAGE_VA_MASK)) : 0))
422
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +0200423static void vmi_update_pte(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100424{
425 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
426 vmi_ops.update_pte(ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
427}
428
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +0200429static void vmi_update_pte_defer(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100430{
431 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
432 vmi_ops.update_pte(ptep, vmi_flags_addr_defer(mm, addr, VMI_PAGE_PT, 0));
433}
434
435static void vmi_set_pte(pte_t *ptep, pte_t pte)
436{
437 /* XXX because of set_pmd_pte, this can be called on PT or PD layers */
438 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE | VMI_PAGE_PD);
439 vmi_ops.set_pte(pte, ptep, VMI_PAGE_PT);
440}
441
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +0200442static 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 +0100443{
444 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
445 vmi_ops.set_pte(pte, ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
446}
447
448static void vmi_set_pmd(pmd_t *pmdp, pmd_t pmdval)
449{
450#ifdef CONFIG_X86_PAE
451 const pte_t pte = { pmdval.pmd, pmdval.pmd >> 32 };
452 vmi_check_page_type(__pa(pmdp) >> PAGE_SHIFT, VMI_PAGE_PMD);
453#else
454 const pte_t pte = { pmdval.pud.pgd.pgd };
455 vmi_check_page_type(__pa(pmdp) >> PAGE_SHIFT, VMI_PAGE_PGD);
456#endif
457 vmi_ops.set_pte(pte, (pte_t *)pmdp, VMI_PAGE_PD);
458}
459
460#ifdef CONFIG_X86_PAE
461
462static void vmi_set_pte_atomic(pte_t *ptep, pte_t pteval)
463{
464 /*
465 * XXX This is called from set_pmd_pte, but at both PT
466 * and PD layers so the VMI_PAGE_PT flag is wrong. But
467 * it is only called for large page mapping changes,
468 * the Xen backend, doesn't support large pages, and the
469 * ESX backend doesn't depend on the flag.
470 */
471 set_64bit((unsigned long long *)ptep,pte_val(pteval));
472 vmi_ops.update_pte(ptep, VMI_PAGE_PT);
473}
474
475static void vmi_set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
476{
477 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
478 vmi_ops.set_pte(pte, ptep, vmi_flags_addr_defer(mm, addr, VMI_PAGE_PT, 1));
479}
480
481static void vmi_set_pud(pud_t *pudp, pud_t pudval)
482{
483 /* Um, eww */
484 const pte_t pte = { pudval.pgd.pgd, pudval.pgd.pgd >> 32 };
485 vmi_check_page_type(__pa(pudp) >> PAGE_SHIFT, VMI_PAGE_PGD);
486 vmi_ops.set_pte(pte, (pte_t *)pudp, VMI_PAGE_PDP);
487}
488
489static void vmi_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
490{
491 const pte_t pte = { 0 };
492 vmi_check_page_type(__pa(ptep) >> PAGE_SHIFT, VMI_PAGE_PTE);
493 vmi_ops.set_pte(pte, ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
494}
495
Adrian Bunk8eb68fa2007-05-02 19:27:09 +0200496static void vmi_pmd_clear(pmd_t *pmd)
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100497{
498 const pte_t pte = { 0 };
499 vmi_check_page_type(__pa(pmd) >> PAGE_SHIFT, VMI_PAGE_PMD);
500 vmi_ops.set_pte(pte, (pte_t *)pmd, VMI_PAGE_PD);
501}
502#endif
503
504#ifdef CONFIG_SMP
Zachary Amsdenc6b36e92007-03-05 00:30:43 -0800505static void __devinit
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100506vmi_startup_ipi_hook(int phys_apicid, unsigned long start_eip,
507 unsigned long start_esp)
508{
Zachary Amsdenc6b36e92007-03-05 00:30:43 -0800509 struct vmi_ap_state ap;
510
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100511 /* Default everything to zero. This is fine for most GPRs. */
512 memset(&ap, 0, sizeof(struct vmi_ap_state));
513
514 ap.gdtr_limit = GDT_SIZE - 1;
515 ap.gdtr_base = (unsigned long) get_cpu_gdt_table(phys_apicid);
516
517 ap.idtr_limit = IDT_ENTRIES * 8 - 1;
518 ap.idtr_base = (unsigned long) idt_table;
519
520 ap.ldtr = 0;
521
522 ap.cs = __KERNEL_CS;
523 ap.eip = (unsigned long) start_eip;
524 ap.ss = __KERNEL_DS;
525 ap.esp = (unsigned long) start_esp;
526
527 ap.ds = __USER_DS;
528 ap.es = __USER_DS;
Jeremy Fitzhardinge7c3576d2007-05-02 19:27:16 +0200529 ap.fs = __KERNEL_PERCPU;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100530 ap.gs = 0;
531
532 ap.eflags = 0;
533
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100534#ifdef CONFIG_X86_PAE
535 /* efer should match BSP efer. */
536 if (cpu_has_nx) {
537 unsigned l, h;
538 rdmsr(MSR_EFER, l, h);
539 ap.efer = (unsigned long long) h << 32 | l;
540 }
541#endif
542
543 ap.cr3 = __pa(swapper_pg_dir);
544 /* Protected mode, paging, AM, WP, NE, MP. */
545 ap.cr0 = 0x80050023;
546 ap.cr4 = mmu_cr4_features;
Zachary Amsdenc6b36e92007-03-05 00:30:43 -0800547 vmi_ops.set_initial_ap_state((u32)&ap, phys_apicid);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100548}
549#endif
550
Zachary Amsden49f19712007-04-08 16:04:01 -0700551static void vmi_set_lazy_mode(int mode)
552{
553 static DEFINE_PER_CPU(int, lazy_mode);
554
555 if (!vmi_ops.set_lazy_mode)
556 return;
557
558 /* Modes should never nest or overlap */
559 BUG_ON(__get_cpu_var(lazy_mode) && !(mode == PARAVIRT_LAZY_NONE ||
560 mode == PARAVIRT_LAZY_FLUSH));
561
562 if (mode == PARAVIRT_LAZY_FLUSH) {
563 vmi_ops.set_lazy_mode(0);
564 vmi_ops.set_lazy_mode(__get_cpu_var(lazy_mode));
565 } else {
566 vmi_ops.set_lazy_mode(mode);
567 __get_cpu_var(lazy_mode) = mode;
568 }
569}
570
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100571static inline int __init check_vmi_rom(struct vrom_header *rom)
572{
573 struct pci_header *pci;
574 struct pnp_header *pnp;
575 const char *manufacturer = "UNKNOWN";
576 const char *product = "UNKNOWN";
577 const char *license = "unspecified";
578
579 if (rom->rom_signature != 0xaa55)
580 return 0;
581 if (rom->vrom_signature != VMI_SIGNATURE)
582 return 0;
583 if (rom->api_version_maj != VMI_API_REV_MAJOR ||
584 rom->api_version_min+1 < VMI_API_REV_MINOR+1) {
585 printk(KERN_WARNING "VMI: Found mismatched rom version %d.%d\n",
586 rom->api_version_maj,
587 rom->api_version_min);
588 return 0;
589 }
590
591 /*
592 * Relying on the VMI_SIGNATURE field is not 100% safe, so check
593 * the PCI header and device type to make sure this is really a
594 * VMI device.
595 */
596 if (!rom->pci_header_offs) {
597 printk(KERN_WARNING "VMI: ROM does not contain PCI header.\n");
598 return 0;
599 }
600
601 pci = (struct pci_header *)((char *)rom+rom->pci_header_offs);
602 if (pci->vendorID != PCI_VENDOR_ID_VMWARE ||
603 pci->deviceID != PCI_DEVICE_ID_VMWARE_VMI) {
604 /* Allow it to run... anyways, but warn */
605 printk(KERN_WARNING "VMI: ROM from unknown manufacturer\n");
606 }
607
608 if (rom->pnp_header_offs) {
609 pnp = (struct pnp_header *)((char *)rom+rom->pnp_header_offs);
610 if (pnp->manufacturer_offset)
611 manufacturer = (const char *)rom+pnp->manufacturer_offset;
612 if (pnp->product_offset)
613 product = (const char *)rom+pnp->product_offset;
614 }
615
616 if (rom->license_offs)
617 license = (char *)rom+rom->license_offs;
618
619 printk(KERN_INFO "VMI: Found %s %s, API version %d.%d, ROM version %d.%d\n",
620 manufacturer, product,
621 rom->api_version_maj, rom->api_version_min,
622 pci->rom_version_maj, pci->rom_version_min);
623
Andi Kleen302cf932007-03-16 21:07:36 +0100624 /* Don't allow BSD/MIT here for now because we don't want to end up
625 with any binary only shim layers */
626 if (strcmp(license, "GPL") && strcmp(license, "GPL v2")) {
627 printk(KERN_WARNING "VMI: Non GPL license `%s' found for ROM. Not used.\n",
628 license);
629 return 0;
630 }
631
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100632 return 1;
633}
634
635/*
636 * Probe for the VMI option ROM
637 */
638static inline int __init probe_vmi_rom(void)
639{
640 unsigned long base;
641
642 /* VMI ROM is in option ROM area, check signature */
643 for (base = 0xC0000; base < 0xE0000; base += 2048) {
644 struct vrom_header *romstart;
645 romstart = (struct vrom_header *)isa_bus_to_virt(base);
646 if (check_vmi_rom(romstart)) {
647 vmi_rom = romstart;
648 return 1;
649 }
650 }
651 return 0;
652}
653
654/*
655 * VMI setup common to all processors
656 */
657void vmi_bringup(void)
658{
659 /* We must establish the lowmem mapping for MMU ops to work */
Zachary Amsden772205f2007-03-05 00:30:41 -0800660 if (vmi_ops.set_linear_mapping)
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200661 vmi_ops.set_linear_mapping(0, (void *)__PAGE_OFFSET, max_low_pfn, 0);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100662}
663
664/*
Zachary Amsden772205f2007-03-05 00:30:41 -0800665 * Return a pointer to a VMI function or NULL if unimplemented
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100666 */
667static void *vmi_get_function(int vmicall)
668{
669 u64 reloc;
670 const struct vmi_relocation_info *rel = (struct vmi_relocation_info *)&reloc;
671 reloc = call_vrom_long_func(vmi_rom, get_reloc, vmicall);
672 BUG_ON(rel->type == VMI_RELOCATION_JUMP_REL);
673 if (rel->type == VMI_RELOCATION_CALL_REL)
674 return (void *)rel->eip;
675 else
Zachary Amsden772205f2007-03-05 00:30:41 -0800676 return NULL;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100677}
678
679/*
680 * Helper macro for making the VMI paravirt-ops fill code readable.
Zachary Amsden772205f2007-03-05 00:30:41 -0800681 * For unimplemented operations, fall back to default, unless nop
682 * is returned by the ROM.
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100683 */
684#define para_fill(opname, vmicall) \
685do { \
686 reloc = call_vrom_long_func(vmi_rom, get_reloc, \
687 VMI_CALL_##vmicall); \
Zachary Amsden0492c372007-04-12 19:28:46 -0700688 if (rel->type == VMI_RELOCATION_CALL_REL) \
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100689 paravirt_ops.opname = (void *)rel->eip; \
Zachary Amsden0492c372007-04-12 19:28:46 -0700690 else if (rel->type == VMI_RELOCATION_NOP) \
Zachary Amsden772205f2007-03-05 00:30:41 -0800691 paravirt_ops.opname = (void *)vmi_nop; \
Zachary Amsden0492c372007-04-12 19:28:46 -0700692 else if (rel->type != VMI_RELOCATION_NONE) \
693 printk(KERN_WARNING "VMI: Unknown relocation " \
694 "type %d for " #vmicall"\n",\
695 rel->type); \
Zachary Amsden772205f2007-03-05 00:30:41 -0800696} while (0)
697
698/*
699 * Helper macro for making the VMI paravirt-ops fill code readable.
700 * For cached operations which do not match the VMI ROM ABI and must
701 * go through a tranlation stub. Ignore NOPs, since it is not clear
702 * a NOP * VMI function corresponds to a NOP paravirt-op when the
703 * functions are not in 1-1 correspondence.
704 */
705#define para_wrap(opname, wrapper, cache, vmicall) \
706do { \
707 reloc = call_vrom_long_func(vmi_rom, get_reloc, \
708 VMI_CALL_##vmicall); \
709 BUG_ON(rel->type == VMI_RELOCATION_JUMP_REL); \
710 if (rel->type == VMI_RELOCATION_CALL_REL) { \
711 paravirt_ops.opname = wrapper; \
712 vmi_ops.cache = (void *)rel->eip; \
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100713 } \
714} while (0)
715
716/*
717 * Activate the VMI interface and switch into paravirtualized mode
718 */
719static inline int __init activate_vmi(void)
720{
721 short kernel_cs;
722 u64 reloc;
723 const struct vmi_relocation_info *rel = (struct vmi_relocation_info *)&reloc;
724
725 if (call_vrom_func(vmi_rom, vmi_init) != 0) {
726 printk(KERN_ERR "VMI ROM failed to initialize!");
727 return 0;
728 }
729 savesegment(cs, kernel_cs);
730
731 paravirt_ops.paravirt_enabled = 1;
732 paravirt_ops.kernel_rpl = kernel_cs & SEGMENT_RPL_MASK;
733
734 paravirt_ops.patch = vmi_patch;
735 paravirt_ops.name = "vmi";
736
737 /*
738 * Many of these operations are ABI compatible with VMI.
739 * This means we can fill in the paravirt-ops with direct
740 * pointers into the VMI ROM. If the calling convention for
741 * these operations changes, this code needs to be updated.
742 *
743 * Exceptions
744 * CPUID paravirt-op uses pointers, not the native ISA
745 * halt has no VMI equivalent; all VMI halts are "safe"
746 * no MSR support yet - just trap and emulate. VMI uses the
747 * same ABI as the native ISA, but Linux wants exceptions
748 * from bogus MSR read / write handled
749 * rdpmc is not yet used in Linux
750 */
751
Zachary Amsden772205f2007-03-05 00:30:41 -0800752 /* CPUID is special, so very special it gets wrapped like a present */
753 para_wrap(cpuid, vmi_cpuid, cpuid, CPUID);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100754
755 para_fill(clts, CLTS);
756 para_fill(get_debugreg, GetDR);
757 para_fill(set_debugreg, SetDR);
758 para_fill(read_cr0, GetCR0);
759 para_fill(read_cr2, GetCR2);
760 para_fill(read_cr3, GetCR3);
761 para_fill(read_cr4, GetCR4);
762 para_fill(write_cr0, SetCR0);
763 para_fill(write_cr2, SetCR2);
764 para_fill(write_cr3, SetCR3);
765 para_fill(write_cr4, SetCR4);
766 para_fill(save_fl, GetInterruptMask);
767 para_fill(restore_fl, SetInterruptMask);
768 para_fill(irq_disable, DisableInterrupts);
769 para_fill(irq_enable, EnableInterrupts);
Zachary Amsden772205f2007-03-05 00:30:41 -0800770
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100771 para_fill(wbinvd, WBINVD);
Zachary Amsden772205f2007-03-05 00:30:41 -0800772 para_fill(read_tsc, RDTSC);
773
774 /* The following we emulate with trap and emulate for now */
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100775 /* paravirt_ops.read_msr = vmi_rdmsr */
776 /* paravirt_ops.write_msr = vmi_wrmsr */
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100777 /* paravirt_ops.rdpmc = vmi_rdpmc */
778
Zachary Amsden772205f2007-03-05 00:30:41 -0800779 /* TR interface doesn't pass TR value, wrap */
780 para_wrap(load_tr_desc, vmi_set_tr, set_tr, SetTR);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100781
782 /* LDT is special, too */
Zachary Amsden772205f2007-03-05 00:30:41 -0800783 para_wrap(set_ldt, vmi_set_ldt, _set_ldt, SetLDT);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100784
785 para_fill(load_gdt, SetGDT);
786 para_fill(load_idt, SetIDT);
787 para_fill(store_gdt, GetGDT);
788 para_fill(store_idt, GetIDT);
789 para_fill(store_tr, GetTR);
790 paravirt_ops.load_tls = vmi_load_tls;
791 para_fill(write_ldt_entry, WriteLDTEntry);
792 para_fill(write_gdt_entry, WriteGDTEntry);
793 para_fill(write_idt_entry, WriteIDTEntry);
Zachary Amsden772205f2007-03-05 00:30:41 -0800794 para_wrap(load_esp0, vmi_load_esp0, set_kernel_stack, UpdateKernelStack);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100795 para_fill(set_iopl_mask, SetIOPLMask);
Zachary Amsden772205f2007-03-05 00:30:41 -0800796 para_fill(io_delay, IODelay);
Zachary Amsden49f19712007-04-08 16:04:01 -0700797 para_wrap(set_lazy_mode, vmi_set_lazy_mode, set_lazy_mode, SetLazyMode);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100798
Zachary Amsden772205f2007-03-05 00:30:41 -0800799 /* user and kernel flush are just handled with different flags to FlushTLB */
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200800 para_wrap(flush_tlb_user, vmi_flush_tlb_user, _flush_tlb, FlushTLB);
801 para_wrap(flush_tlb_kernel, vmi_flush_tlb_kernel, _flush_tlb, FlushTLB);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100802 para_fill(flush_tlb_single, InvalPage);
803
804 /*
805 * Until a standard flag format can be agreed on, we need to
806 * implement these as wrappers in Linux. Get the VMI ROM
807 * function pointers for the two backend calls.
808 */
809#ifdef CONFIG_X86_PAE
810 vmi_ops.set_pte = vmi_get_function(VMI_CALL_SetPxELong);
811 vmi_ops.update_pte = vmi_get_function(VMI_CALL_UpdatePxELong);
812#else
813 vmi_ops.set_pte = vmi_get_function(VMI_CALL_SetPxE);
814 vmi_ops.update_pte = vmi_get_function(VMI_CALL_UpdatePxE);
815#endif
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100816
Zachary Amsden772205f2007-03-05 00:30:41 -0800817 if (vmi_ops.set_pte) {
818 paravirt_ops.set_pte = vmi_set_pte;
819 paravirt_ops.set_pte_at = vmi_set_pte_at;
820 paravirt_ops.set_pmd = vmi_set_pmd;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100821#ifdef CONFIG_X86_PAE
Zachary Amsden772205f2007-03-05 00:30:41 -0800822 paravirt_ops.set_pte_atomic = vmi_set_pte_atomic;
823 paravirt_ops.set_pte_present = vmi_set_pte_present;
824 paravirt_ops.set_pud = vmi_set_pud;
825 paravirt_ops.pte_clear = vmi_pte_clear;
826 paravirt_ops.pmd_clear = vmi_pmd_clear;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100827#endif
Zachary Amsden772205f2007-03-05 00:30:41 -0800828 }
829
830 if (vmi_ops.update_pte) {
831 paravirt_ops.pte_update = vmi_update_pte;
832 paravirt_ops.pte_update_defer = vmi_update_pte_defer;
833 }
834
835 vmi_ops.allocate_page = vmi_get_function(VMI_CALL_AllocatePage);
836 if (vmi_ops.allocate_page) {
837 paravirt_ops.alloc_pt = vmi_allocate_pt;
838 paravirt_ops.alloc_pd = vmi_allocate_pd;
839 paravirt_ops.alloc_pd_clone = vmi_allocate_pd_clone;
840 }
841
842 vmi_ops.release_page = vmi_get_function(VMI_CALL_ReleasePage);
843 if (vmi_ops.release_page) {
844 paravirt_ops.release_pt = vmi_release_pt;
845 paravirt_ops.release_pd = vmi_release_pd;
846 }
Zachary Amsdeneeef9c62007-05-02 19:27:16 +0200847
848 /* Set linear is needed in all cases */
849 vmi_ops.set_linear_mapping = vmi_get_function(VMI_CALL_SetLinearMapping);
850#ifdef CONFIG_HIGHPTE
851 if (vmi_ops.set_linear_mapping)
852 paravirt_ops.kmap_atomic_pte = vmi_kmap_atomic_pte;
Jeremy Fitzhardingea27fe802007-05-02 19:27:15 +0200853#endif
Zachary Amsden772205f2007-03-05 00:30:41 -0800854
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100855 /*
856 * These MUST always be patched. Don't support indirect jumps
857 * through these operations, as the VMI interface may use either
858 * a jump or a call to get to these operations, depending on
859 * the backend. They are performance critical anyway, so requiring
860 * a patch is not a big problem.
861 */
862 paravirt_ops.irq_enable_sysexit = (void *)0xfeedbab0;
863 paravirt_ops.iret = (void *)0xbadbab0;
864
865#ifdef CONFIG_SMP
Zachary Amsden772205f2007-03-05 00:30:41 -0800866 para_wrap(startup_ipi_hook, vmi_startup_ipi_hook, set_initial_ap_state, SetInitialAPState);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100867#endif
868
869#ifdef CONFIG_X86_LOCAL_APIC
Zachary Amsden772205f2007-03-05 00:30:41 -0800870 para_fill(apic_read, APICRead);
871 para_fill(apic_write, APICWrite);
872 para_fill(apic_write_atomic, APICWrite);
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100873#endif
874
875 /*
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100876 * Check for VMI timer functionality by probing for a cycle frequency method
877 */
878 reloc = call_vrom_long_func(vmi_rom, get_reloc, VMI_CALL_GetCycleFrequency);
Zachary Amsden772205f2007-03-05 00:30:41 -0800879 if (!disable_vmi_timer && rel->type != VMI_RELOCATION_NONE) {
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100880 vmi_timer_ops.get_cycle_frequency = (void *)rel->eip;
881 vmi_timer_ops.get_cycle_counter =
882 vmi_get_function(VMI_CALL_GetCycleCounter);
883 vmi_timer_ops.get_wallclock =
884 vmi_get_function(VMI_CALL_GetWallclockTime);
885 vmi_timer_ops.wallclock_updated =
886 vmi_get_function(VMI_CALL_WallclockUpdated);
887 vmi_timer_ops.set_alarm = vmi_get_function(VMI_CALL_SetAlarm);
888 vmi_timer_ops.cancel_alarm =
889 vmi_get_function(VMI_CALL_CancelAlarm);
890 paravirt_ops.time_init = vmi_time_init;
891 paravirt_ops.get_wallclock = vmi_get_wallclock;
892 paravirt_ops.set_wallclock = vmi_set_wallclock;
893#ifdef CONFIG_X86_LOCAL_APIC
Zachary Amsdene0bb8642007-05-02 19:27:16 +0200894 paravirt_ops.setup_boot_clock = vmi_time_bsp_init;
895 paravirt_ops.setup_secondary_clock = vmi_time_ap_init;
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100896#endif
Zachary Amsden6cb9a832007-03-05 00:30:35 -0800897 paravirt_ops.get_scheduled_cycles = vmi_get_sched_cycles;
Zachary Amsden1182d852007-03-05 00:30:36 -0800898 paravirt_ops.get_cpu_khz = vmi_cpu_khz;
Zachary Amsden772205f2007-03-05 00:30:41 -0800899
900 /* We have true wallclock functions; disable CMOS clock sync */
901 no_sync_cmos_clock = 1;
902 } else {
903 disable_noidle = 1;
904 disable_vmi_timer = 1;
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100905 }
Zachary Amsden772205f2007-03-05 00:30:41 -0800906
Zachary Amsdene0bb8642007-05-02 19:27:16 +0200907 para_fill(safe_halt, Halt);
Zachary Amsdenbbab4f32007-02-13 13:26:21 +0100908
909 /*
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100910 * Alternative instruction rewriting doesn't happen soon enough
911 * to convert VMI_IRET to a call instead of a jump; so we have
912 * to do this before IRQs get reenabled. Fortunately, it is
913 * idempotent.
914 */
915 apply_paravirt(__start_parainstructions, __stop_parainstructions);
916
917 vmi_bringup();
918
919 return 1;
920}
921
922#undef para_fill
923
924void __init vmi_init(void)
925{
926 unsigned long flags;
927
928 if (!vmi_rom)
929 probe_vmi_rom();
930 else
931 check_vmi_rom(vmi_rom);
932
933 /* In case probing for or validating the ROM failed, basil */
934 if (!vmi_rom)
935 return;
936
937 reserve_top_address(-vmi_rom->virtual_top);
938
939 local_irq_save(flags);
940 activate_vmi();
Zachary Amsden7507ba32007-03-05 00:30:34 -0800941
942#ifdef CONFIG_X86_IO_APIC
Zachary Amsden772205f2007-03-05 00:30:41 -0800943 /* This is virtual hardware; timer routing is wired correctly */
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100944 no_timer_check = 1;
945#endif
946 local_irq_restore(flags & X86_EFLAGS_IF);
947}
948
949static int __init parse_vmi(char *arg)
950{
951 if (!arg)
952 return -EINVAL;
953
Zachary Amsdeneda08b12007-03-05 00:30:38 -0800954 if (!strcmp(arg, "disable_pge")) {
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100955 clear_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability);
956 disable_pge = 1;
957 } else if (!strcmp(arg, "disable_pse")) {
958 clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
959 disable_pse = 1;
960 } else if (!strcmp(arg, "disable_sep")) {
961 clear_bit(X86_FEATURE_SEP, boot_cpu_data.x86_capability);
962 disable_sep = 1;
963 } else if (!strcmp(arg, "disable_tsc")) {
964 clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
965 disable_tsc = 1;
966 } else if (!strcmp(arg, "disable_mtrr")) {
967 clear_bit(X86_FEATURE_MTRR, boot_cpu_data.x86_capability);
968 disable_mtrr = 1;
Zachary Amsden772205f2007-03-05 00:30:41 -0800969 } else if (!strcmp(arg, "disable_timer")) {
970 disable_vmi_timer = 1;
971 disable_noidle = 1;
Zachary Amsden7507ba32007-03-05 00:30:34 -0800972 } else if (!strcmp(arg, "disable_noidle"))
973 disable_noidle = 1;
Zachary Amsden7ce0bcf2007-02-13 13:26:21 +0100974 return 0;
975}
976
977early_param("vmi", parse_vmi);