aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2013-10-07 12:47:52 -0400
committerAlexander Graf <agraf@suse.de>2013-10-17 09:18:28 -0400
commit9975f5e3692d320b4259a4d2edd8a979adb1e535 (patch)
tree1d76ca99ca876230944faae97a8a4ba2ed1e9c9f
parent7aa79938f7d76f5865d0b2a2d9bbe2337560261f (diff)
kvm: powerpc: book3s: Add a new config variable CONFIG_KVM_BOOK3S_HV_POSSIBLE
This help ups to select the relevant code in the kernel code when we later move HV and PR bits as seperate modules. The patch also makes the config options for PR KVM selectable Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r--arch/powerpc/include/asm/kvm_book3s.h2
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_64.h6
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_asm.h2
-rw-r--r--arch/powerpc/include/asm/kvm_host.h10
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h2
-rw-r--r--arch/powerpc/kernel/asm-offsets.c8
-rw-r--r--arch/powerpc/kernel/idle_power7.S2
-rw-r--r--arch/powerpc/kvm/Kconfig18
-rw-r--r--arch/powerpc/kvm/Makefile12
-rw-r--r--arch/powerpc/kvm/book3s_exports.c5
10 files changed, 43 insertions, 24 deletions
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index 5c07d10e3c41..99ef8711e906 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -199,8 +199,6 @@ static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
199 return vcpu->arch.book3s; 199 return vcpu->arch.book3s;
200} 200}
201 201
202extern void kvm_return_point(void);
203
204/* Also add subarch specific defines */ 202/* Also add subarch specific defines */
205 203
206#ifdef CONFIG_KVM_BOOK3S_32_HANDLER 204#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h
index e6ee7fd32d12..bf0fa8b0a883 100644
--- a/arch/powerpc/include/asm/kvm_book3s_64.h
+++ b/arch/powerpc/include/asm/kvm_book3s_64.h
@@ -35,7 +35,7 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)
35 35
36#define SPAPR_TCE_SHIFT 12 36#define SPAPR_TCE_SHIFT 12
37 37
38#ifdef CONFIG_KVM_BOOK3S_64_HV 38#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
39#define KVM_DEFAULT_HPT_ORDER 24 /* 16MB HPT by default */ 39#define KVM_DEFAULT_HPT_ORDER 24 /* 16MB HPT by default */
40extern unsigned long kvm_rma_pages; 40extern unsigned long kvm_rma_pages;
41#endif 41#endif
@@ -278,7 +278,7 @@ static inline int is_vrma_hpte(unsigned long hpte_v)
278 (HPTE_V_1TB_SEG | (VRMA_VSID << (40 - 16))); 278 (HPTE_V_1TB_SEG | (VRMA_VSID << (40 - 16)));
279} 279}
280 280
281#ifdef CONFIG_KVM_BOOK3S_64_HV 281#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
282/* 282/*
283 * Note modification of an HPTE; set the HPTE modified bit 283 * Note modification of an HPTE; set the HPTE modified bit
284 * if anyone is interested. 284 * if anyone is interested.
@@ -289,6 +289,6 @@ static inline void note_hpte_modification(struct kvm *kvm,
289 if (atomic_read(&kvm->arch.hpte_mod_interest)) 289 if (atomic_read(&kvm->arch.hpte_mod_interest))
290 rev->guest_rpte |= HPTE_GR_MODIFIED; 290 rev->guest_rpte |= HPTE_GR_MODIFIED;
291} 291}
292#endif /* CONFIG_KVM_BOOK3S_64_HV */ 292#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
293 293
294#endif /* __ASM_KVM_BOOK3S_64_H__ */ 294#endif /* __ASM_KVM_BOOK3S_64_H__ */
diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h b/arch/powerpc/include/asm/kvm_book3s_asm.h
index 62737113c2b9..0bd9348a4db9 100644
--- a/arch/powerpc/include/asm/kvm_book3s_asm.h
+++ b/arch/powerpc/include/asm/kvm_book3s_asm.h
@@ -83,7 +83,7 @@ struct kvmppc_host_state {
83 u8 restore_hid5; 83 u8 restore_hid5;
84 u8 napping; 84 u8 napping;
85 85
86#ifdef CONFIG_KVM_BOOK3S_64_HV 86#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
87 u8 hwthread_req; 87 u8 hwthread_req;
88 u8 hwthread_state; 88 u8 hwthread_state;
89 u8 host_ipi; 89 u8 host_ipi;
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 9e9f689106e2..61ce4dca45d3 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -224,15 +224,15 @@ struct revmap_entry {
224#define KVMPPC_GOT_PAGE 0x80 224#define KVMPPC_GOT_PAGE 0x80
225 225
226struct kvm_arch_memory_slot { 226struct kvm_arch_memory_slot {
227#ifdef CONFIG_KVM_BOOK3S_64_HV 227#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
228 unsigned long *rmap; 228 unsigned long *rmap;
229 unsigned long *slot_phys; 229 unsigned long *slot_phys;
230#endif /* CONFIG_KVM_BOOK3S_64_HV */ 230#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
231}; 231};
232 232
233struct kvm_arch { 233struct kvm_arch {
234 unsigned int lpid; 234 unsigned int lpid;
235#ifdef CONFIG_KVM_BOOK3S_64_HV 235#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
236 unsigned long hpt_virt; 236 unsigned long hpt_virt;
237 struct revmap_entry *revmap; 237 struct revmap_entry *revmap;
238 unsigned int host_lpid; 238 unsigned int host_lpid;
@@ -256,7 +256,7 @@ struct kvm_arch {
256 cpumask_t need_tlb_flush; 256 cpumask_t need_tlb_flush;
257 struct kvmppc_vcore *vcores[KVM_MAX_VCORES]; 257 struct kvmppc_vcore *vcores[KVM_MAX_VCORES];
258 int hpt_cma_alloc; 258 int hpt_cma_alloc;
259#endif /* CONFIG_KVM_BOOK3S_64_HV */ 259#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
260#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE 260#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
261 struct mutex hpt_mutex; 261 struct mutex hpt_mutex;
262#endif 262#endif
@@ -592,7 +592,7 @@ struct kvm_vcpu_arch {
592 struct kvmppc_icp *icp; /* XICS presentation controller */ 592 struct kvmppc_icp *icp; /* XICS presentation controller */
593#endif 593#endif
594 594
595#ifdef CONFIG_KVM_BOOK3S_64_HV 595#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
596 struct kvm_vcpu_arch_shared shregs; 596 struct kvm_vcpu_arch_shared shregs;
597 597
598 unsigned long pgfault_addr; 598 unsigned long pgfault_addr;
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index b15554a26c20..1823f38906c6 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -260,7 +260,7 @@ void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid);
260 260
261struct openpic; 261struct openpic;
262 262
263#ifdef CONFIG_KVM_BOOK3S_64_HV 263#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
264extern void kvm_cma_reserve(void) __init; 264extern void kvm_cma_reserve(void) __init;
265static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) 265static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr)
266{ 266{
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 29796559c2fb..1fbb2b63195c 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -445,7 +445,7 @@ int main(void)
445 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); 445 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr));
446 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr)); 446 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr));
447 DEFINE(VCPU_PC, offsetof(struct kvm_vcpu, arch.pc)); 447 DEFINE(VCPU_PC, offsetof(struct kvm_vcpu, arch.pc));
448#ifdef CONFIG_KVM_BOOK3S_64_HV 448#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
449 DEFINE(VCPU_MSR, offsetof(struct kvm_vcpu, arch.shregs.msr)); 449 DEFINE(VCPU_MSR, offsetof(struct kvm_vcpu, arch.shregs.msr));
450 DEFINE(VCPU_SRR0, offsetof(struct kvm_vcpu, arch.shregs.srr0)); 450 DEFINE(VCPU_SRR0, offsetof(struct kvm_vcpu, arch.shregs.srr0));
451 DEFINE(VCPU_SRR1, offsetof(struct kvm_vcpu, arch.shregs.srr1)); 451 DEFINE(VCPU_SRR1, offsetof(struct kvm_vcpu, arch.shregs.srr1));
@@ -476,7 +476,7 @@ int main(void)
476 DEFINE(KVM_LPID, offsetof(struct kvm, arch.lpid)); 476 DEFINE(KVM_LPID, offsetof(struct kvm, arch.lpid));
477 477
478 /* book3s */ 478 /* book3s */
479#ifdef CONFIG_KVM_BOOK3S_64_HV 479#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
480 DEFINE(KVM_SDR1, offsetof(struct kvm, arch.sdr1)); 480 DEFINE(KVM_SDR1, offsetof(struct kvm, arch.sdr1));
481 DEFINE(KVM_HOST_LPID, offsetof(struct kvm, arch.host_lpid)); 481 DEFINE(KVM_HOST_LPID, offsetof(struct kvm, arch.host_lpid));
482 DEFINE(KVM_HOST_LPCR, offsetof(struct kvm, arch.host_lpcr)); 482 DEFINE(KVM_HOST_LPCR, offsetof(struct kvm, arch.host_lpcr));
@@ -586,7 +586,7 @@ int main(void)
586 HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5); 586 HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5);
587 HSTATE_FIELD(HSTATE_NAPPING, napping); 587 HSTATE_FIELD(HSTATE_NAPPING, napping);
588 588
589#ifdef CONFIG_KVM_BOOK3S_64_HV 589#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
590 HSTATE_FIELD(HSTATE_HWTHREAD_REQ, hwthread_req); 590 HSTATE_FIELD(HSTATE_HWTHREAD_REQ, hwthread_req);
591 HSTATE_FIELD(HSTATE_HWTHREAD_STATE, hwthread_state); 591 HSTATE_FIELD(HSTATE_HWTHREAD_STATE, hwthread_state);
592 HSTATE_FIELD(HSTATE_KVM_VCPU, kvm_vcpu); 592 HSTATE_FIELD(HSTATE_KVM_VCPU, kvm_vcpu);
@@ -602,7 +602,7 @@ int main(void)
602 HSTATE_FIELD(HSTATE_DABR, dabr); 602 HSTATE_FIELD(HSTATE_DABR, dabr);
603 HSTATE_FIELD(HSTATE_DECEXP, dec_expires); 603 HSTATE_FIELD(HSTATE_DECEXP, dec_expires);
604 DEFINE(IPI_PRIORITY, IPI_PRIORITY); 604 DEFINE(IPI_PRIORITY, IPI_PRIORITY);
605#endif /* CONFIG_KVM_BOOK3S_64_HV */ 605#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
606 606
607#ifdef CONFIG_PPC_BOOK3S_64 607#ifdef CONFIG_PPC_BOOK3S_64
608 HSTATE_FIELD(HSTATE_CFAR, cfar); 608 HSTATE_FIELD(HSTATE_CFAR, cfar);
diff --git a/arch/powerpc/kernel/idle_power7.S b/arch/powerpc/kernel/idle_power7.S
index e11863f4e595..847e40e62fce 100644
--- a/arch/powerpc/kernel/idle_power7.S
+++ b/arch/powerpc/kernel/idle_power7.S
@@ -84,7 +84,7 @@ _GLOBAL(power7_nap)
84 std r9,_MSR(r1) 84 std r9,_MSR(r1)
85 std r1,PACAR1(r13) 85 std r1,PACAR1(r13)
86 86
87#ifdef CONFIG_KVM_BOOK3S_64_HV 87#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
88 /* Tell KVM we're napping */ 88 /* Tell KVM we're napping */
89 li r4,KVM_HWTHREAD_IN_NAP 89 li r4,KVM_HWTHREAD_IN_NAP
90 stb r4,HSTATE_HWTHREAD_STATE(r13) 90 stb r4,HSTATE_HWTHREAD_STATE(r13)
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
index d0665f231e6f..a96d7c32f785 100644
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -39,6 +39,9 @@ config KVM_BOOK3S_PR_POSSIBLE
39 select KVM_MMIO 39 select KVM_MMIO
40 select MMU_NOTIFIER 40 select MMU_NOTIFIER
41 41
42config KVM_BOOK3S_HV_POSSIBLE
43 bool
44
42config KVM_BOOK3S_32 45config KVM_BOOK3S_32
43 tristate "KVM support for PowerPC book3s_32 processors" 46 tristate "KVM support for PowerPC book3s_32 processors"
44 depends on PPC_BOOK3S_32 && !SMP && !PTE_64BIT 47 depends on PPC_BOOK3S_32 && !SMP && !PTE_64BIT
@@ -59,6 +62,7 @@ config KVM_BOOK3S_64
59 depends on PPC_BOOK3S_64 62 depends on PPC_BOOK3S_64
60 select KVM_BOOK3S_64_HANDLER 63 select KVM_BOOK3S_64_HANDLER
61 select KVM 64 select KVM
65 select KVM_BOOK3S_PR_POSSIBLE if !KVM_BOOK3S_HV_POSSIBLE
62 ---help--- 66 ---help---
63 Support running unmodified book3s_64 and book3s_32 guest kernels 67 Support running unmodified book3s_64 and book3s_32 guest kernels
64 in virtual machines on book3s_64 host processors. 68 in virtual machines on book3s_64 host processors.
@@ -71,6 +75,7 @@ config KVM_BOOK3S_64
71config KVM_BOOK3S_64_HV 75config KVM_BOOK3S_64_HV
72 bool "KVM support for POWER7 and PPC970 using hypervisor mode in host" 76 bool "KVM support for POWER7 and PPC970 using hypervisor mode in host"
73 depends on KVM_BOOK3S_64 77 depends on KVM_BOOK3S_64
78 select KVM_BOOK3S_HV_POSSIBLE
74 select MMU_NOTIFIER 79 select MMU_NOTIFIER
75 select CMA 80 select CMA
76 ---help--- 81 ---help---
@@ -89,9 +94,20 @@ config KVM_BOOK3S_64_HV
89 If unsure, say N. 94 If unsure, say N.
90 95
91config KVM_BOOK3S_64_PR 96config KVM_BOOK3S_64_PR
92 def_bool y 97 bool "KVM support without using hypervisor mode in host"
93 depends on KVM_BOOK3S_64 && !KVM_BOOK3S_64_HV 98 depends on KVM_BOOK3S_64 && !KVM_BOOK3S_64_HV
94 select KVM_BOOK3S_PR_POSSIBLE 99 select KVM_BOOK3S_PR_POSSIBLE
100 ---help---
101 Support running guest kernels in virtual machines on processors
102 without using hypervisor mode in the host, by running the
103 guest in user mode (problem state) and emulating all
104 privileged instructions and registers.
105
106 This is not as fast as using hypervisor mode, but works on
107 machines where hypervisor mode is not available or not usable,
108 and can emulate processors that are different from the host
109 processor, including emulating 32-bit processors on a 64-bit
110 host.
95 111
96config KVM_BOOKE_HV 112config KVM_BOOKE_HV
97 bool 113 bool
diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile
index 104e8dcf4336..fa17b337bb96 100644
--- a/arch/powerpc/kvm/Makefile
+++ b/arch/powerpc/kvm/Makefile
@@ -57,7 +57,6 @@ kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) := \
57 book3s_64_vio_hv.o 57 book3s_64_vio_hv.o
58 58
59kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_PR) := \ 59kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_PR) := \
60 $(KVM)/coalesced_mmio.o \
61 fpu.o \ 60 fpu.o \
62 book3s_paired_singles.o \ 61 book3s_paired_singles.o \
63 book3s_pr.o \ 62 book3s_pr.o \
@@ -69,10 +68,15 @@ kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_PR) := \
69 book3s_64_mmu.o \ 68 book3s_64_mmu.o \
70 book3s_32_mmu.o 69 book3s_32_mmu.o
71 70
72kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_PR) += \ 71ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
72kvm-book3s_64-module-objs := \
73 $(KVM)/coalesced_mmio.o
74
75kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
73 book3s_rmhandlers.o 76 book3s_rmhandlers.o
77endif
74 78
75kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) := \ 79kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \
76 book3s_hv.o \ 80 book3s_hv.o \
77 book3s_hv_interrupts.o \ 81 book3s_hv_interrupts.o \
78 book3s_64_mmu_hv.o 82 book3s_64_mmu_hv.o
@@ -91,7 +95,7 @@ kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \
91kvm-book3s_64-objs-$(CONFIG_KVM_XICS) += \ 95kvm-book3s_64-objs-$(CONFIG_KVM_XICS) += \
92 book3s_xics.o 96 book3s_xics.o
93 97
94kvm-book3s_64-module-objs := \ 98kvm-book3s_64-module-objs += \
95 $(KVM)/kvm_main.o \ 99 $(KVM)/kvm_main.o \
96 $(KVM)/eventfd.o \ 100 $(KVM)/eventfd.o \
97 powerpc.o \ 101 powerpc.o \
diff --git a/arch/powerpc/kvm/book3s_exports.c b/arch/powerpc/kvm/book3s_exports.c
index 7057a02f0906..852989a9bad3 100644
--- a/arch/powerpc/kvm/book3s_exports.c
+++ b/arch/powerpc/kvm/book3s_exports.c
@@ -20,9 +20,10 @@
20#include <linux/export.h> 20#include <linux/export.h>
21#include <asm/kvm_book3s.h> 21#include <asm/kvm_book3s.h>
22 22
23#ifdef CONFIG_KVM_BOOK3S_64_HV 23#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
24EXPORT_SYMBOL_GPL(kvmppc_hv_entry_trampoline); 24EXPORT_SYMBOL_GPL(kvmppc_hv_entry_trampoline);
25#else 25#endif
26#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
26EXPORT_SYMBOL_GPL(kvmppc_entry_trampoline); 27EXPORT_SYMBOL_GPL(kvmppc_entry_trampoline);
27EXPORT_SYMBOL_GPL(kvmppc_load_up_fpu); 28EXPORT_SYMBOL_GPL(kvmppc_load_up_fpu);
28#ifdef CONFIG_ALTIVEC 29#ifdef CONFIG_ALTIVEC