aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2008-02-22 12:21:37 -0500
committerAvi Kivity <avi@qumranet.com>2008-04-27 05:00:27 -0400
commit2f333bcb4edd8daef99dabe4e7df8277af73cff1 (patch)
treec984466e7756e0910bf470a094558b52bd10df33 /arch/x86/kvm/x86.c
parent9f81128591ca1e9907f2e7a7b195e33232167d60 (diff)
KVM: MMU: hypercall based pte updates and TLB flushes
Hypercall based pte updates are faster than faults, and also allow use of the lazy MMU mode to batch operations. Don't report the feature if two dimensional paging is enabled. [avi: - one mmu_op hypercall instead of one per op - allow 64-bit gpa on hypercall - don't pass host errors (-ENOMEM) to guest] [akpm: warning fix on i386] Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 03ba402c476a..63afca1c295f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -832,6 +832,9 @@ int kvm_dev_ioctl_check_extension(long ext)
832 case KVM_CAP_NR_MEMSLOTS: 832 case KVM_CAP_NR_MEMSLOTS:
833 r = KVM_MEMORY_SLOTS; 833 r = KVM_MEMORY_SLOTS;
834 break; 834 break;
835 case KVM_CAP_PV_MMU:
836 r = !tdp_enabled;
837 break;
835 default: 838 default:
836 r = 0; 839 r = 0;
837 break; 840 break;
@@ -2452,9 +2455,19 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu)
2452} 2455}
2453EXPORT_SYMBOL_GPL(kvm_emulate_halt); 2456EXPORT_SYMBOL_GPL(kvm_emulate_halt);
2454 2457
2458static inline gpa_t hc_gpa(struct kvm_vcpu *vcpu, unsigned long a0,
2459 unsigned long a1)
2460{
2461 if (is_long_mode(vcpu))
2462 return a0;
2463 else
2464 return a0 | ((gpa_t)a1 << 32);
2465}
2466
2455int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) 2467int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
2456{ 2468{
2457 unsigned long nr, a0, a1, a2, a3, ret; 2469 unsigned long nr, a0, a1, a2, a3, ret;
2470 int r = 1;
2458 2471
2459 kvm_x86_ops->cache_regs(vcpu); 2472 kvm_x86_ops->cache_regs(vcpu);
2460 2473
@@ -2476,6 +2489,9 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
2476 case KVM_HC_VAPIC_POLL_IRQ: 2489 case KVM_HC_VAPIC_POLL_IRQ:
2477 ret = 0; 2490 ret = 0;
2478 break; 2491 break;
2492 case KVM_HC_MMU_OP:
2493 r = kvm_pv_mmu_op(vcpu, a0, hc_gpa(vcpu, a1, a2), &ret);
2494 break;
2479 default: 2495 default:
2480 ret = -KVM_ENOSYS; 2496 ret = -KVM_ENOSYS;
2481 break; 2497 break;
@@ -2483,7 +2499,7 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
2483 vcpu->arch.regs[VCPU_REGS_RAX] = ret; 2499 vcpu->arch.regs[VCPU_REGS_RAX] = ret;
2484 kvm_x86_ops->decache_regs(vcpu); 2500 kvm_x86_ops->decache_regs(vcpu);
2485 ++vcpu->stat.hypercalls; 2501 ++vcpu->stat.hypercalls;
2486 return 0; 2502 return r;
2487} 2503}
2488EXPORT_SYMBOL_GPL(kvm_emulate_hypercall); 2504EXPORT_SYMBOL_GPL(kvm_emulate_hypercall);
2489 2505