aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/kvm/kvm.h1
-rw-r--r--drivers/kvm/mmu.c1
-rw-r--r--drivers/kvm/mmu.h44
-rw-r--r--drivers/kvm/svm.c1
-rw-r--r--drivers/kvm/vmx.c1
-rw-r--r--drivers/kvm/x86.c7
-rw-r--r--drivers/kvm/x86.h44
7 files changed, 55 insertions, 44 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 668a8300365d..c040bb3ac819 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -396,6 +396,7 @@ void kvm_arch_hardware_disable(void *garbage);
396int kvm_arch_hardware_setup(void); 396int kvm_arch_hardware_setup(void);
397void kvm_arch_hardware_unsetup(void); 397void kvm_arch_hardware_unsetup(void);
398void kvm_arch_check_processor_compat(void *rtn); 398void kvm_arch_check_processor_compat(void *rtn);
399int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu);
399 400
400void kvm_free_physmem(struct kvm *kvm); 401void kvm_free_physmem(struct kvm *kvm);
401 402
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index da1dedb497b8..1dc0e8c02c70 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -20,6 +20,7 @@
20#include "vmx.h" 20#include "vmx.h"
21#include "kvm.h" 21#include "kvm.h"
22#include "x86.h" 22#include "x86.h"
23#include "mmu.h"
23 24
24#include <linux/types.h> 25#include <linux/types.h>
25#include <linux/string.h> 26#include <linux/string.h>
diff --git a/drivers/kvm/mmu.h b/drivers/kvm/mmu.h
new file mode 100644
index 000000000000..9ebfd1cafe62
--- /dev/null
+++ b/drivers/kvm/mmu.h
@@ -0,0 +1,44 @@
1#ifndef __KVM_X86_MMU_H
2#define __KVM_X86_MMU_H
3
4#include "kvm.h"
5
6static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
7{
8 if (unlikely(vcpu->kvm->n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES))
9 __kvm_mmu_free_some_pages(vcpu);
10}
11
12static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu)
13{
14 if (likely(vcpu->arch.mmu.root_hpa != INVALID_PAGE))
15 return 0;
16
17 return kvm_mmu_load(vcpu);
18}
19
20static inline int is_long_mode(struct kvm_vcpu *vcpu)
21{
22#ifdef CONFIG_X86_64
23 return vcpu->arch.shadow_efer & EFER_LME;
24#else
25 return 0;
26#endif
27}
28
29static inline int is_pae(struct kvm_vcpu *vcpu)
30{
31 return vcpu->arch.cr4 & X86_CR4_PAE;
32}
33
34static inline int is_pse(struct kvm_vcpu *vcpu)
35{
36 return vcpu->arch.cr4 & X86_CR4_PSE;
37}
38
39static inline int is_paging(struct kvm_vcpu *vcpu)
40{
41 return vcpu->arch.cr0 & X86_CR0_PG;
42}
43
44#endif
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 7888638c02e8..e606f6d18669 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -17,6 +17,7 @@
17#include "kvm_svm.h" 17#include "kvm_svm.h"
18#include "x86_emulate.h" 18#include "x86_emulate.h"
19#include "irq.h" 19#include "irq.h"
20#include "mmu.h"
20 21
21#include <linux/module.h> 22#include <linux/module.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index cf78ebb2f36e..d0f431d4fe4d 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -21,6 +21,7 @@
21#include "irq.h" 21#include "irq.h"
22#include "vmx.h" 22#include "vmx.h"
23#include "segment_descriptor.h" 23#include "segment_descriptor.h"
24#include "mmu.h"
24 25
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/kernel.h> 27#include <linux/kernel.h>
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 5a2f33a84e4f..60f9722a06ba 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -19,6 +19,7 @@
19#include "x86_emulate.h" 19#include "x86_emulate.h"
20#include "segment_descriptor.h" 20#include "segment_descriptor.h"
21#include "irq.h" 21#include "irq.h"
22#include "mmu.h"
22 23
23#include <linux/kvm.h> 24#include <linux/kvm.h>
24#include <linux/fs.h> 25#include <linux/fs.h>
@@ -3139,3 +3140,9 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
3139 3140
3140 return 0; 3141 return 0;
3141} 3142}
3143
3144int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
3145{
3146 return vcpu->arch.mp_state == VCPU_MP_STATE_RUNNABLE
3147 || vcpu->arch.mp_state == VCPU_MP_STATE_SIPI_RECEIVED;
3148}
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index 0e01ac75268c..0da4be9b0bad 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -334,44 +334,6 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
334 334
335int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code); 335int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code);
336 336
337static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
338{
339 if (unlikely(vcpu->kvm->n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES))
340 __kvm_mmu_free_some_pages(vcpu);
341}
342
343static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu)
344{
345 if (likely(vcpu->arch.mmu.root_hpa != INVALID_PAGE))
346 return 0;
347
348 return kvm_mmu_load(vcpu);
349}
350
351static inline int is_long_mode(struct kvm_vcpu *vcpu)
352{
353#ifdef CONFIG_X86_64
354 return vcpu->arch.shadow_efer & EFER_LME;
355#else
356 return 0;
357#endif
358}
359
360static inline int is_pae(struct kvm_vcpu *vcpu)
361{
362 return vcpu->arch.cr4 & X86_CR4_PAE;
363}
364
365static inline int is_pse(struct kvm_vcpu *vcpu)
366{
367 return vcpu->arch.cr4 & X86_CR4_PSE;
368}
369
370static inline int is_paging(struct kvm_vcpu *vcpu)
371{
372 return vcpu->arch.cr0 & X86_CR0_PG;
373}
374
375int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); 337int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
376int complete_pio(struct kvm_vcpu *vcpu); 338int complete_pio(struct kvm_vcpu *vcpu);
377 339
@@ -490,10 +452,4 @@ static inline void kvm_inject_gp(struct kvm_vcpu *vcpu, u32 error_code)
490#define TSS_REDIRECTION_SIZE (256 / 8) 452#define TSS_REDIRECTION_SIZE (256 / 8)
491#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) 453#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
492 454
493static inline int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
494{
495 return vcpu->arch.mp_state == VCPU_MP_STATE_RUNNABLE
496 || vcpu->arch.mp_state == VCPU_MP_STATE_SIPI_RECEIVED;
497}
498
499#endif 455#endif