aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/kvm_host.h1
-rw-r--r--arch/x86/kvm/x86.c6
-rw-r--r--include/linux/kvm_host.h5
3 files changed, 12 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 3fde5b322534..4915b7c8f2ec 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -243,6 +243,7 @@ struct kvm_mmu {
243 void (*free)(struct kvm_vcpu *vcpu); 243 void (*free)(struct kvm_vcpu *vcpu);
244 gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access, 244 gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access,
245 u32 *error); 245 u32 *error);
246 gpa_t (*translate_gpa)(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access);
246 void (*prefetch_page)(struct kvm_vcpu *vcpu, 247 void (*prefetch_page)(struct kvm_vcpu *vcpu,
247 struct kvm_mmu_page *page); 248 struct kvm_mmu_page *page);
248 int (*sync_page)(struct kvm_vcpu *vcpu, 249 int (*sync_page)(struct kvm_vcpu *vcpu,
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 48b74d2fbfb7..2364c2cad891 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3448,6 +3448,11 @@ void kvm_get_segment(struct kvm_vcpu *vcpu,
3448 kvm_x86_ops->get_segment(vcpu, var, seg); 3448 kvm_x86_ops->get_segment(vcpu, var, seg);
3449} 3449}
3450 3450
3451static gpa_t translate_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access)
3452{
3453 return gpa;
3454}
3455
3451gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3456gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3452{ 3457{
3453 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; 3458 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
@@ -5659,6 +5664,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
5659 5664
5660 vcpu->arch.emulate_ctxt.ops = &emulate_ops; 5665 vcpu->arch.emulate_ctxt.ops = &emulate_ops;
5661 vcpu->arch.mmu.root_hpa = INVALID_PAGE; 5666 vcpu->arch.mmu.root_hpa = INVALID_PAGE;
5667 vcpu->arch.mmu.translate_gpa = translate_gpa;
5662 if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu)) 5668 if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu))
5663 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; 5669 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
5664 else 5670 else
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f2ecdd52032b..917e68ff5ed2 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -534,6 +534,11 @@ static inline gpa_t gfn_to_gpa(gfn_t gfn)
534 return (gpa_t)gfn << PAGE_SHIFT; 534 return (gpa_t)gfn << PAGE_SHIFT;
535} 535}
536 536
537static inline gfn_t gpa_to_gfn(gpa_t gpa)
538{
539 return (gfn_t)(gpa >> PAGE_SHIFT);
540}
541
537static inline hpa_t pfn_to_hpa(pfn_t pfn) 542static inline hpa_t pfn_to_hpa(pfn_t pfn)
538{ 543{
539 return (hpa_t)pfn << PAGE_SHIFT; 544 return (hpa_t)pfn << PAGE_SHIFT;