aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2008-02-24 04:20:43 -0500
committerAvi Kivity <avi@qumranet.com>2008-04-27 04:53:26 -0400
commit2d3ad1f40c841bd3e97d30d423eea53915d085dc (patch)
tree39f4a5a7814cc306d002366e1af922d32b7713c5 /arch/x86/kvm/x86.c
parent05da45583de9b383dc81dd695fe248431d6c9f2b (diff)
KVM: Prefix control register accessors with kvm_ to avoid namespace pollution
Names like 'set_cr3()' look dangerously close to affecting the host. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0458bd516185..dbcff38dfcc3 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -237,7 +237,7 @@ out:
237 return changed; 237 return changed;
238} 238}
239 239
240void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) 240void kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
241{ 241{
242 if (cr0 & CR0_RESERVED_BITS) { 242 if (cr0 & CR0_RESERVED_BITS) {
243 printk(KERN_DEBUG "set_cr0: 0x%lx #GP, reserved bits 0x%lx\n", 243 printk(KERN_DEBUG "set_cr0: 0x%lx #GP, reserved bits 0x%lx\n",
@@ -295,15 +295,15 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
295 kvm_mmu_reset_context(vcpu); 295 kvm_mmu_reset_context(vcpu);
296 return; 296 return;
297} 297}
298EXPORT_SYMBOL_GPL(set_cr0); 298EXPORT_SYMBOL_GPL(kvm_set_cr0);
299 299
300void lmsw(struct kvm_vcpu *vcpu, unsigned long msw) 300void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw)
301{ 301{
302 set_cr0(vcpu, (vcpu->arch.cr0 & ~0x0ful) | (msw & 0x0f)); 302 kvm_set_cr0(vcpu, (vcpu->arch.cr0 & ~0x0ful) | (msw & 0x0f));
303} 303}
304EXPORT_SYMBOL_GPL(lmsw); 304EXPORT_SYMBOL_GPL(kvm_lmsw);
305 305
306void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) 306void kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
307{ 307{
308 if (cr4 & CR4_RESERVED_BITS) { 308 if (cr4 & CR4_RESERVED_BITS) {
309 printk(KERN_DEBUG "set_cr4: #GP, reserved bits\n"); 309 printk(KERN_DEBUG "set_cr4: #GP, reserved bits\n");
@@ -334,9 +334,9 @@ void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
334 vcpu->arch.cr4 = cr4; 334 vcpu->arch.cr4 = cr4;
335 kvm_mmu_reset_context(vcpu); 335 kvm_mmu_reset_context(vcpu);
336} 336}
337EXPORT_SYMBOL_GPL(set_cr4); 337EXPORT_SYMBOL_GPL(kvm_set_cr4);
338 338
339void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) 339void kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
340{ 340{
341 if (cr3 == vcpu->arch.cr3 && !pdptrs_changed(vcpu)) { 341 if (cr3 == vcpu->arch.cr3 && !pdptrs_changed(vcpu)) {
342 kvm_mmu_flush_tlb(vcpu); 342 kvm_mmu_flush_tlb(vcpu);
@@ -388,9 +388,9 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
388 } 388 }
389 up_read(&vcpu->kvm->slots_lock); 389 up_read(&vcpu->kvm->slots_lock);
390} 390}
391EXPORT_SYMBOL_GPL(set_cr3); 391EXPORT_SYMBOL_GPL(kvm_set_cr3);
392 392
393void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8) 393void kvm_set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8)
394{ 394{
395 if (cr8 & CR8_RESERVED_BITS) { 395 if (cr8 & CR8_RESERVED_BITS) {
396 printk(KERN_DEBUG "set_cr8: #GP, reserved bits 0x%lx\n", cr8); 396 printk(KERN_DEBUG "set_cr8: #GP, reserved bits 0x%lx\n", cr8);
@@ -402,16 +402,16 @@ void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8)
402 else 402 else
403 vcpu->arch.cr8 = cr8; 403 vcpu->arch.cr8 = cr8;
404} 404}
405EXPORT_SYMBOL_GPL(set_cr8); 405EXPORT_SYMBOL_GPL(kvm_set_cr8);
406 406
407unsigned long get_cr8(struct kvm_vcpu *vcpu) 407unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu)
408{ 408{
409 if (irqchip_in_kernel(vcpu->kvm)) 409 if (irqchip_in_kernel(vcpu->kvm))
410 return kvm_lapic_get_cr8(vcpu); 410 return kvm_lapic_get_cr8(vcpu);
411 else 411 else
412 return vcpu->arch.cr8; 412 return vcpu->arch.cr8;
413} 413}
414EXPORT_SYMBOL_GPL(get_cr8); 414EXPORT_SYMBOL_GPL(kvm_get_cr8);
415 415
416/* 416/*
417 * List of msr numbers which we expose to userspace through KVM_GET_MSRS 417 * List of msr numbers which we expose to userspace through KVM_GET_MSRS
@@ -2462,7 +2462,7 @@ void realmode_lidt(struct kvm_vcpu *vcpu, u16 limit, unsigned long base)
2462void realmode_lmsw(struct kvm_vcpu *vcpu, unsigned long msw, 2462void realmode_lmsw(struct kvm_vcpu *vcpu, unsigned long msw,
2463 unsigned long *rflags) 2463 unsigned long *rflags)
2464{ 2464{
2465 lmsw(vcpu, msw); 2465 kvm_lmsw(vcpu, msw);
2466 *rflags = kvm_x86_ops->get_rflags(vcpu); 2466 *rflags = kvm_x86_ops->get_rflags(vcpu);
2467} 2467}
2468 2468
@@ -2479,7 +2479,7 @@ unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr)
2479 case 4: 2479 case 4:
2480 return vcpu->arch.cr4; 2480 return vcpu->arch.cr4;
2481 case 8: 2481 case 8:
2482 return get_cr8(vcpu); 2482 return kvm_get_cr8(vcpu);
2483 default: 2483 default:
2484 vcpu_printf(vcpu, "%s: unexpected cr %u\n", __FUNCTION__, cr); 2484 vcpu_printf(vcpu, "%s: unexpected cr %u\n", __FUNCTION__, cr);
2485 return 0; 2485 return 0;
@@ -2491,20 +2491,20 @@ void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long val,
2491{ 2491{
2492 switch (cr) { 2492 switch (cr) {
2493 case 0: 2493 case 0:
2494 set_cr0(vcpu, mk_cr_64(vcpu->arch.cr0, val)); 2494 kvm_set_cr0(vcpu, mk_cr_64(vcpu->arch.cr0, val));
2495 *rflags = kvm_x86_ops->get_rflags(vcpu); 2495 *rflags = kvm_x86_ops->get_rflags(vcpu);
2496 break; 2496 break;
2497 case 2: 2497 case 2:
2498 vcpu->arch.cr2 = val; 2498 vcpu->arch.cr2 = val;
2499 break; 2499 break;
2500 case 3: 2500 case 3:
2501 set_cr3(vcpu, val); 2501 kvm_set_cr3(vcpu, val);
2502 break; 2502 break;
2503 case 4: 2503 case 4:
2504 set_cr4(vcpu, mk_cr_64(vcpu->arch.cr4, val)); 2504 kvm_set_cr4(vcpu, mk_cr_64(vcpu->arch.cr4, val));
2505 break; 2505 break;
2506 case 8: 2506 case 8:
2507 set_cr8(vcpu, val & 0xfUL); 2507 kvm_set_cr8(vcpu, val & 0xfUL);
2508 break; 2508 break;
2509 default: 2509 default:
2510 vcpu_printf(vcpu, "%s: unexpected cr %u\n", __FUNCTION__, cr); 2510 vcpu_printf(vcpu, "%s: unexpected cr %u\n", __FUNCTION__, cr);
@@ -2602,7 +2602,7 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu,
2602 struct kvm_run *kvm_run) 2602 struct kvm_run *kvm_run)
2603{ 2603{
2604 kvm_run->if_flag = (kvm_x86_ops->get_rflags(vcpu) & X86_EFLAGS_IF) != 0; 2604 kvm_run->if_flag = (kvm_x86_ops->get_rflags(vcpu) & X86_EFLAGS_IF) != 0;
2605 kvm_run->cr8 = get_cr8(vcpu); 2605 kvm_run->cr8 = kvm_get_cr8(vcpu);
2606 kvm_run->apic_base = kvm_get_apic_base(vcpu); 2606 kvm_run->apic_base = kvm_get_apic_base(vcpu);
2607 if (irqchip_in_kernel(vcpu->kvm)) 2607 if (irqchip_in_kernel(vcpu->kvm))
2608 kvm_run->ready_for_interrupt_injection = 1; 2608 kvm_run->ready_for_interrupt_injection = 1;
@@ -2803,7 +2803,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2803 2803
2804 /* re-sync apic's tpr */ 2804 /* re-sync apic's tpr */
2805 if (!irqchip_in_kernel(vcpu->kvm)) 2805 if (!irqchip_in_kernel(vcpu->kvm))
2806 set_cr8(vcpu, kvm_run->cr8); 2806 kvm_set_cr8(vcpu, kvm_run->cr8);
2807 2807
2808 if (vcpu->arch.pio.cur_count) { 2808 if (vcpu->arch.pio.cur_count) {
2809 r = complete_pio(vcpu); 2809 r = complete_pio(vcpu);
@@ -2961,7 +2961,7 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
2961 sregs->cr2 = vcpu->arch.cr2; 2961 sregs->cr2 = vcpu->arch.cr2;
2962 sregs->cr3 = vcpu->arch.cr3; 2962 sregs->cr3 = vcpu->arch.cr3;
2963 sregs->cr4 = vcpu->arch.cr4; 2963 sregs->cr4 = vcpu->arch.cr4;
2964 sregs->cr8 = get_cr8(vcpu); 2964 sregs->cr8 = kvm_get_cr8(vcpu);
2965 sregs->efer = vcpu->arch.shadow_efer; 2965 sregs->efer = vcpu->arch.shadow_efer;
2966 sregs->apic_base = kvm_get_apic_base(vcpu); 2966 sregs->apic_base = kvm_get_apic_base(vcpu);
2967 2967
@@ -3007,7 +3007,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
3007 mmu_reset_needed |= vcpu->arch.cr3 != sregs->cr3; 3007 mmu_reset_needed |= vcpu->arch.cr3 != sregs->cr3;
3008 vcpu->arch.cr3 = sregs->cr3; 3008 vcpu->arch.cr3 = sregs->cr3;
3009 3009
3010 set_cr8(vcpu, sregs->cr8); 3010 kvm_set_cr8(vcpu, sregs->cr8);
3011 3011
3012 mmu_reset_needed |= vcpu->arch.shadow_efer != sregs->efer; 3012 mmu_reset_needed |= vcpu->arch.shadow_efer != sregs->efer;
3013 kvm_x86_ops->set_efer(vcpu, sregs->efer); 3013 kvm_x86_ops->set_efer(vcpu, sregs->efer);