aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2011-12-12 07:36:37 -0500
committerAvi Kivity <avi@redhat.com>2012-03-05 07:52:37 -0500
commit697d3899dcb4bcd918d060a92db57b794e56b077 (patch)
tree173cdd849eca204fec8b64ea520b619372c3d970 /arch/powerpc/kernel
parent06ce2c63d933e347f8a199f123a8a293619ab3d2 (diff)
KVM: PPC: Implement MMIO emulation support for Book3S HV guests
This provides the low-level support for MMIO emulation in Book3S HV guests. When the guest tries to map a page which is not covered by any memslot, that page is taken to be an MMIO emulation page. Instead of inserting a valid HPTE, we insert an HPTE that has the valid bit clear but another hypervisor software-use bit set, which we call HPTE_V_ABSENT, to indicate that this is an absent page. An absent page is treated much like a valid page as far as guest hcalls (H_ENTER, H_REMOVE, H_READ etc.) are concerned, except of course that an absent HPTE doesn't need to be invalidated with tlbie since it was never valid as far as the hardware is concerned. When the guest accesses a page for which there is an absent HPTE, it will take a hypervisor data storage interrupt (HDSI) since we now set the VPM1 bit in the LPCR. Our HDSI handler for HPTE-not-present faults looks up the hash table and if it finds an absent HPTE mapping the requested virtual address, will switch to kernel mode and handle the fault in kvmppc_book3s_hv_page_fault(), which at present just calls kvmppc_hv_emulate_mmio() to set up the MMIO emulation. This is based on an earlier patch by Benjamin Herrenschmidt, but since heavily reworked. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/asm-offsets.c1
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S8
2 files changed, 5 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index e7bfcf81b746..8e0db0b12dd0 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -455,6 +455,7 @@ int main(void)
455 DEFINE(KVM_LAST_VCPU, offsetof(struct kvm, arch.last_vcpu)); 455 DEFINE(KVM_LAST_VCPU, offsetof(struct kvm, arch.last_vcpu));
456 DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr)); 456 DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr));
457 DEFINE(KVM_RMOR, offsetof(struct kvm, arch.rmor)); 457 DEFINE(KVM_RMOR, offsetof(struct kvm, arch.rmor));
458 DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v));
458 DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr)); 459 DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr));
459 DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); 460 DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar));
460#endif 461#endif
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 15c5a4f6de01..8bea12086b67 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -100,14 +100,14 @@ data_access_not_stab:
100END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB) 100END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
101#endif 101#endif
102 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD, 102 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD,
103 KVMTEST_PR, 0x300) 103 KVMTEST, 0x300)
104 104
105 . = 0x380 105 . = 0x380
106 .globl data_access_slb_pSeries 106 .globl data_access_slb_pSeries
107data_access_slb_pSeries: 107data_access_slb_pSeries:
108 HMT_MEDIUM 108 HMT_MEDIUM
109 SET_SCRATCH0(r13) 109 SET_SCRATCH0(r13)
110 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x380) 110 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380)
111 std r3,PACA_EXSLB+EX_R3(r13) 111 std r3,PACA_EXSLB+EX_R3(r13)
112 mfspr r3,SPRN_DAR 112 mfspr r3,SPRN_DAR
113#ifdef __DISABLED__ 113#ifdef __DISABLED__
@@ -329,8 +329,8 @@ do_stab_bolted_pSeries:
329 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD) 329 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD)
330#endif /* CONFIG_POWER4_ONLY */ 330#endif /* CONFIG_POWER4_ONLY */
331 331
332 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x300) 332 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
333 KVM_HANDLER_PR_SKIP(PACA_EXSLB, EXC_STD, 0x380) 333 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
334 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400) 334 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400)
335 KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480) 335 KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480)
336 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900) 336 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900)