aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-23 11:42:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-23 11:42:08 -0400
commitf4b10bc60a310916bab5413f821b99ef845cac17 (patch)
tree904532e8cd93b88261f21427c4ec4917d4b3e79d /include/linux
parent53ee7569ce8beb3fd3fc0817116c29298d72353f (diff)
parentc8cfbb555eb3632bf3dcbe1a591c1f4d0c28681c (diff)
Merge branch 'kvm-updates/2.6.40' of git://git.kernel.org/pub/scm/virt/kvm/kvm
* 'kvm-updates/2.6.40' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (131 commits) KVM: MMU: Use ptep_user for cmpxchg_gpte() KVM: Fix kvm mmu_notifier initialization order KVM: Add documentation for KVM_CAP_NR_VCPUS KVM: make guest mode entry to be rcu quiescent state KVM: x86 emulator: Make jmp far emulation into a separate function KVM: x86 emulator: Rename emulate_grpX() to em_grpX() KVM: x86 emulator: Remove unused arg from emulate_pop() KVM: x86 emulator: Remove unused arg from writeback() KVM: x86 emulator: Remove unused arg from read_descriptor() KVM: x86 emulator: Remove unused arg from seg_override() KVM: Validate userspace_addr of memslot when registered KVM: MMU: Clean up gpte reading with copy_from_user() KVM: PPC: booke: add sregs support KVM: PPC: booke: save/restore VRSAVE (a.k.a. USPRG0) KVM: PPC: use ticks, not usecs, for exit timing KVM: PPC: fix exit accounting for SPRs, tlbwe, tlbsx KVM: PPC: e500: emulate SVR KVM: VMX: Cache vmcs segment fields KVM: x86 emulator: consolidate segment accessors KVM: VMX: Avoid reading %rip unnecessarily when handling exceptions ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/kvm.h6
-rw-r--r--include/linux/kvm_host.h30
2 files changed, 30 insertions, 6 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index ea2dc1a2e13d..55ef181521ff 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -541,6 +541,9 @@ struct kvm_ppc_pvinfo {
541#define KVM_CAP_PPC_GET_PVINFO 57 541#define KVM_CAP_PPC_GET_PVINFO 57
542#define KVM_CAP_PPC_IRQ_LEVEL 58 542#define KVM_CAP_PPC_IRQ_LEVEL 58
543#define KVM_CAP_ASYNC_PF 59 543#define KVM_CAP_ASYNC_PF 59
544#define KVM_CAP_TSC_CONTROL 60
545#define KVM_CAP_GET_TSC_KHZ 61
546#define KVM_CAP_PPC_BOOKE_SREGS 62
544 547
545#ifdef KVM_CAP_IRQ_ROUTING 548#ifdef KVM_CAP_IRQ_ROUTING
546 549
@@ -677,6 +680,9 @@ struct kvm_clock_data {
677#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 680#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
678/* Available with KVM_CAP_PPC_GET_PVINFO */ 681/* Available with KVM_CAP_PPC_GET_PVINFO */
679#define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) 682#define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo)
683/* Available with KVM_CAP_TSC_CONTROL */
684#define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2)
685#define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3)
680 686
681/* 687/*
682 * ioctls for vcpu fds 688 * ioctls for vcpu fds
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ab428552af8e..b9c3299c6a55 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -27,6 +27,10 @@
27 27
28#include <asm/kvm_host.h> 28#include <asm/kvm_host.h>
29 29
30#ifndef KVM_MMIO_SIZE
31#define KVM_MMIO_SIZE 8
32#endif
33
30/* 34/*
31 * vcpu->requests bit members 35 * vcpu->requests bit members
32 */ 36 */
@@ -43,7 +47,6 @@
43#define KVM_REQ_DEACTIVATE_FPU 10 47#define KVM_REQ_DEACTIVATE_FPU 10
44#define KVM_REQ_EVENT 11 48#define KVM_REQ_EVENT 11
45#define KVM_REQ_APF_HALT 12 49#define KVM_REQ_APF_HALT 12
46#define KVM_REQ_NMI 13
47 50
48#define KVM_USERSPACE_IRQ_SOURCE_ID 0 51#define KVM_USERSPACE_IRQ_SOURCE_ID 0
49 52
@@ -133,7 +136,8 @@ struct kvm_vcpu {
133 int mmio_read_completed; 136 int mmio_read_completed;
134 int mmio_is_write; 137 int mmio_is_write;
135 int mmio_size; 138 int mmio_size;
136 unsigned char mmio_data[8]; 139 int mmio_index;
140 unsigned char mmio_data[KVM_MMIO_SIZE];
137 gpa_t mmio_phys_addr; 141 gpa_t mmio_phys_addr;
138#endif 142#endif
139 143
@@ -292,9 +296,10 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
292} 296}
293 297
294#define kvm_for_each_vcpu(idx, vcpup, kvm) \ 298#define kvm_for_each_vcpu(idx, vcpup, kvm) \
295 for (idx = 0, vcpup = kvm_get_vcpu(kvm, idx); \ 299 for (idx = 0; \
296 idx < atomic_read(&kvm->online_vcpus) && vcpup; \ 300 idx < atomic_read(&kvm->online_vcpus) && \
297 vcpup = kvm_get_vcpu(kvm, ++idx)) 301 (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
302 idx++)
298 303
299int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id); 304int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
300void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); 305void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
@@ -365,7 +370,6 @@ pfn_t gfn_to_pfn_prot(struct kvm *kvm, gfn_t gfn, bool write_fault,
365 bool *writable); 370 bool *writable);
366pfn_t gfn_to_pfn_memslot(struct kvm *kvm, 371pfn_t gfn_to_pfn_memslot(struct kvm *kvm,
367 struct kvm_memory_slot *slot, gfn_t gfn); 372 struct kvm_memory_slot *slot, gfn_t gfn);
368int memslot_id(struct kvm *kvm, gfn_t gfn);
369void kvm_release_pfn_dirty(pfn_t); 373void kvm_release_pfn_dirty(pfn_t);
370void kvm_release_pfn_clean(pfn_t pfn); 374void kvm_release_pfn_clean(pfn_t pfn);
371void kvm_set_pfn_dirty(pfn_t pfn); 375void kvm_set_pfn_dirty(pfn_t pfn);
@@ -587,8 +591,17 @@ static inline int kvm_deassign_device(struct kvm *kvm,
587 591
588static inline void kvm_guest_enter(void) 592static inline void kvm_guest_enter(void)
589{ 593{
594 BUG_ON(preemptible());
590 account_system_vtime(current); 595 account_system_vtime(current);
591 current->flags |= PF_VCPU; 596 current->flags |= PF_VCPU;
597 /* KVM does not hold any references to rcu protected data when it
598 * switches CPU into a guest mode. In fact switching to a guest mode
599 * is very similar to exiting to userspase from rcu point of view. In
600 * addition CPU may stay in a guest mode for quite a long time (up to
601 * one time slice). Lets treat guest mode as quiescent state, just like
602 * we do with user-mode execution.
603 */
604 rcu_virt_note_context_switch(smp_processor_id());
592} 605}
593 606
594static inline void kvm_guest_exit(void) 607static inline void kvm_guest_exit(void)
@@ -597,6 +610,11 @@ static inline void kvm_guest_exit(void)
597 current->flags &= ~PF_VCPU; 610 current->flags &= ~PF_VCPU;
598} 611}
599 612
613static inline int memslot_id(struct kvm *kvm, gfn_t gfn)
614{
615 return gfn_to_memslot(kvm, gfn)->id;
616}
617
600static inline unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, 618static inline unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot,
601 gfn_t gfn) 619 gfn_t gfn)
602{ 620{