KVM: ppc: Refactor powerpc.c to relocate 440-specific
Subsystems (2)
PATCH 1/1 KVM: ppc: Refactor powerpc.c to relocate 440-specific
# HG changeset patch
# User Hollis Blanchard <[email protected]>
# Date 1222712594 18000
# Node ID 9a6ae4702d83ff58b538b6cd517e0c571b379cfe # Parent 00752aa374758b6cfcc0d7894b2d7bb4ebfbc775
KVM: ppc: Refactor powerpc.c to relocate 440-specific code
This introduces a set of core-provided hooks. For 440, some of these are implemented by booke.c, with the rest in (the new) 44x.c.
Note that these hooks are link-time, not run-time. Since it is not possible to build a single kernel for both e500 and 440 (for example), using function pointers would only add overhead.
Signed-off-by Hollis Blanchard <[email protected]>
arch/powerpc/include/asm/kvm_host.h +3 -0
@@ -73,6 +73,9 @@ struct kvmppc_44x_tlbe {struct kvm_arch { }; + +/* XXX Can't include mmu-44x.h because it redefines struct mm_context. */ +#define PPC44x_TLB_SIZE 64struct kvm_vcpu_arch {/* Unmodified copy of the guest's TLB. */
arch/powerpc/include/asm/kvm_ppc.h +17 -17
@@ -61,23 +61,6 @@ extern void kvmppc_mmu_priv_switch(strucextern void kvmppc_mmu_priv_switch (struct kvm_vcpu *vcpu,int usermode);extern void kvmppc_mmu_switch_pid (struct kvm_vcpu *vcpu,u32 pid); -/* XXX Book E specific */ -extern void kvmppc_tlbe_set_modified (struct kvm_vcpu *vcpu,unsigned int i); - -extern void kvmppc_check_and_deliver_interrupts (struct kvm_vcpu *vcpu); - -static inline void kvmppc_queue_exception (struct kvm_vcpu *vcpu,int exception) -{ -unsigned int priority = exception_priority[exception]; -set_bit (priority, &vcpu->arch.pending_exceptions); -} - -static inline void kvmppc_clear_exception (struct kvm_vcpu *vcpu,int exception) -{ -unsigned int priority = exception_priority[exception]; -clear_bit (priority, &vcpu->arch.pending_exceptions); -} -/* Helper function for "full" MSR writes. No need to call this if only EE is * changing. */ static inline void kvmppc_set_msr (struct kvm_vcpu *vcpu,u32 new_msr)
@@ -99,4 +82,21 @@ static inline void kvmppc_set_pid(struct } } +/* Core-specific hooks */ + +extern int kvmppc_core_check_processor_compat (void ); + +extern void kvmppc_core_vcpu_load (struct kvm_vcpu *vcpu,int cpu); +extern void kvmppc_core_vcpu_put (struct kvm_vcpu *vcpu); + +extern void kvmppc_core_load_guest_debugstate (struct kvm_vcpu *vcpu); +extern void kvmppc_core_load_host_debugstate (struct kvm_vcpu *vcpu); + +extern void kvmppc_core_deliver_interrupts (struct kvm_vcpu *vcpu); +extern int kvmppc_core_pending_dec (struct kvm_vcpu *vcpu); +extern void kvmppc_core_queue_program (struct kvm_vcpu *vcpu); +extern void kvmppc_core_queue_dec (struct kvm_vcpu *vcpu); +extern void kvmppc_core_queue_external (struct kvm_vcpu *vcpu, +struct kvm_interrupt *irq); +#endif /* __POWERPC_KVM_PPC_H__ */
arch/powerpc/kvm/44x.c new file +123 -0
123 lines not on this page · raw message
arch/powerpc/kvm/44x_tlb.h +1 -0
@@ -29,6 +29,7 @@ extern struct kvmppc_44x_tlbe *kvmppc_44 gva_t eaddr);extern struct kvmppc_44x_tlbe *kvmppc_44x_itlb_search (struct kvm_vcpu *vcpu,gva_t eaddr); +extern void kvmppc_tlbe_set_modified (struct kvm_vcpu *vcpu,unsigned int i);/* TLB helper functions */ static inline unsigned int get_tlb_size (const struct kvmppc_44x_tlbe *tlbe)
arch/powerpc/kvm/Kconfig +4 -7
@@ -16,11 +16,9 @@ if VIRTUALIZATION config KVM bool "Kernel-based Virtual Machine (KVM) support" - depends on 44x && EXPERIMENTAL + depends on EXPERIMENTAL select PREEMPT_NOTIFIERS select ANON_INODES - # We can only run on Book E hosts so far - select KVM_BOOKE ---help--- Support hosting virtualized guest machines. You will also need to select one or more of the processor modules below.
@@ -30,12 +28,11 @@ config KVM If unsure, say N. -config KVM_BOOKE - bool "KVM support for Book E PowerPC processors" +config KVM_440 + bool "KVM support for PowerPC 440 processors" depends on KVM && 44x ---help--- - Provides host support for KVM on Book E PowerPC processors. Currently - this works on 440 processors only. + KVM can run unmodified 440 guest kernels on 440 host processors. config KVM_TRACE bool "KVM trace support"
arch/powerpc/kvm/Makefile +2 -2
@@ -13,5 +13,5 @@ obj-$(CONFIG_KVM) += kvm.o AFLAGS_booke_interrupts.o := -I$(obj) -kvm-booke-objs := booke.o booke_interrupts.o 44x_tlb.o -obj-$(CONFIG_KVM_BOOKE) += kvm-booke.o +kvm-440-objs := booke.o booke_interrupts.o 44x.o 44x_tlb.o +obj-$(CONFIG_KVM_440) += kvm-440.o
arch/powerpc/kvm/booke.c +47 -14
138 lines not on this page · raw message
arch/powerpc/kvm/emulate.c +1 -1
@@ -139,7 +139,7 @@ int kvmppc_emulate_instruction(struct kvswitch (get_op (inst)) {case 3 :/* trap */ printk ("trap!\n" ); -kvmppc_queue_exception (vcpu,BOOKE_INTERRUPT_PROGRAM ); +kvmppc_core_queue_program (vcpu); advance =0 ;break ;
arch/powerpc/kvm/powerpc.c +10 -95
150 lines not on this page · raw message