add e500 support for kvm
Subsystems (2)
PATCH 4/4 add e500 support for kvm
Any chance we could merge struct kvm_vcpu_arch for both 44x and e500?
--- arch/powerpc/include/asm/kvm_asm.h | 7 ++- arch/powerpc/include/asm/kvm_host.h | 112 +++++++++++++++++++++++++++++++++++ arch/powerpc/kernel/asm-offsets.c | 9 +++ arch/powerpc/kvm/44x_tlb.h | 4 + arch/powerpc/kvm/Kconfig | 4 +- arch/powerpc/kvm/Makefile | 7 ++ arch/powerpc/kvm/booke_guest.c | 14 ++++- arch/powerpc/kvm/booke_host.c | 20 ++++-- arch/powerpc/kvm/emulate.c | 88 +++++++++++++++++++++++++++- arch/powerpc/kvm/powerpc.c | 4 + arch/powerpc/kvm/powerpc.h | 4 + 11 files changed, 261 insertions(+), 12 deletions(-)
arch/powerpc/include/asm/kvm_asm.h +6 -1
@@ -42,7 +42,12 @@#define BOOKE_INTERRUPT_DTLB_MISS 13#define BOOKE_INTERRUPT_ITLB_MISS 14#define BOOKE_INTERRUPT_DEBUG 15 -#define BOOKE_MAX_INTERRUPT 15 +#define BOOKE_INTERRUPT_SPE_UNAVAIL 32 +#define BOOKE_INTERRUPT_SPE_FP_DATA 33 +#define BOOKE_INTERRUPT_SPE_FP_ROUND 34 +#define BOOKE_INTERRUPT_PERFORMANCE_MONITOR 35 +#define BOOKE_MAX_INTERRUPT 35 +#define BOOKE_INTERRUPT_NUM (BOOKE_MAX_INTERRUPT + 1)#define RESUME_FLAG_NV (1<<0)/* Reload guest nonvolatile state? */ #define RESUME_FLAG_HOST (1<<1)/* Resume host? */
arch/powerpc/include/asm/kvm_host.h +112 -0
124 lines not on this page · raw message
arch/powerpc/kernel/asm-offsets.c +9 -0
@@ -352,12 +352,15 @@ int main(void)DEFINE (PGD_TABLE_SIZE ,PGD_TABLE_SIZE );#ifdef CONFIG_KVM +# ifdef CONFIG_44xDEFINE (TLBE_BYTES ,sizeof (struct tlbe )); +# endif DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack)); DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid)); DEFINE(VCPU_SHADOW_TLB, offsetof(struct kvm_vcpu, arch.shadow_tlb)); DEFINE(VCPU_SHADOW_MOD, offsetof(struct kvm_vcpu, arch.shadow_tlb_mod)); +DEFINE (SIZEOF_TLB_ARRAY ,sizeof (struct tlb_array )); DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr)); DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr));
@@ -370,6 +373,12 @@ int main(void) DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6)); DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7)); DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid)); + DEFINE(VCPU_PID, offsetof(struct kvm_vcpu, arch.pid)); + DEFINE(VCPU_MAS0, offsetof(struct kvm_vcpu, arch.mas0)); + DEFINE(VCPU_MAS1, offsetof(struct kvm_vcpu, arch.mas1)); + DEFINE(VCPU_MAS2, offsetof(struct kvm_vcpu, arch.mas2)); + DEFINE(VCPU_MAS3, offsetof(struct kvm_vcpu, arch.mas3)); + DEFINE(VCPU_MAS7, offsetof(struct kvm_vcpu, arch.mas7)); DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst)); DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear));
arch/powerpc/kvm/44x_tlb.h +4 -0
@@ -23,6 +23,10 @@#include <linux/kvm_host.h> #include <asm/mmu-44x.h> +#define kvmppc_emul_tlbre (vcpu, val) EMULATE_DONE +#define kvmppc_emul_tlbivax (vcpu, val) EMULATE_DONE +#define kvmppc_tlb_init (vcpu) +extern void kvmppc_dump_tlbs (struct kvm_vcpu *vcpu);extern struct tlbe *kvmppc_tlb_search (struct kvm_vcpu *vcpu,gva_t eaddr,unsigned int pid,unsigned int as);
arch/powerpc/kvm/Kconfig +2 -2
@@ -16,7 +16,7 @@ if VIRTUALIZATION config KVM bool "Kernel-based Virtual Machine (KVM) support" - depends on 44x && EXPERIMENTAL + depends on (44x || E500) && EXPERIMENTAL select PREEMPT_NOTIFIERS select ANON_INODES # We can only run on Book E hosts so far
@@ -32,7 +32,7 @@ config KVM config KVM_BOOKE_HOST bool "KVM host support for Book E PowerPC processors" - depends on KVM && 44x + depends on KVM && (44x || E500) ---help--- Provides host support for KVM on Book E PowerPC processors. Currently this works on 440 processors only.
arch/powerpc/kvm/Makefile +7 -0
@@ -13,5 +13,12 @@ obj-$(CONFIG_KVM) += kvm.o AFLAGS_booke_interrupts.o := -I$(obj) +ifeq ($(CONFIG_44x),y) kvm-booke-host-objs := booke_host.o booke_interrupts.o 44x_tlb.o +endif + +ifeq ($(CONFIG_E500),y) +kvm-booke-host-objs := booke_host.o booke_fsl_interrupts.o e500_tlb.o +endif + obj-$(CONFIG_KVM_BOOKE_HOST) += kvm-booke-host.o
arch/powerpc/kvm/booke_guest.c +13 -1
@@ -53,7 +53,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { { NULL } }; -static const u32 interrupt_msr_mask[16 ] = { +static const u32 interrupt_msr_mask[] = { [BOOKE_INTERRUPT_CRITICAL ] =MSR_ME , [BOOKE_INTERRUPT_MACHINE_CHECK ] =0 , [BOOKE_INTERRUPT_DATA_STORAGE ] =MSR_CE |MSR_ME |MSR_DE ,
@@ -70,6 +70,9 @@ static const u32 interrupt_msr_mask[16] = { [BOOKE_INTERRUPT_DTLB_MISS] = MSR_CE|MSR_ME|MSR_DE, [BOOKE_INTERRUPT_ITLB_MISS] = MSR_CE|MSR_ME|MSR_DE, [BOOKE_INTERRUPT_DEBUG] = MSR_ME, + [BOOKE_INTERRUPT_SPE_UNAVAIL] = MSR_CE|MSR_ME|MSR_DE, + [BOOKE_INTERRUPT_SPE_FP_DATA] = MSR_CE|MSR_ME|MSR_DE, + [BOOKE_INTERRUPT_SPE_FP_ROUND ] =MSR_CE |MSR_ME |MSR_DE };const unsigned char exception_priority[] = {
@@ -89,6 +92,9 @@ const unsigned char exception_priority[] = { [BOOKE_INTERRUPT_EXTERNAL] = 13, [BOOKE_INTERRUPT_FIT] = 14, [BOOKE_INTERRUPT_DECREMENTER] = 15, + [BOOKE_INTERRUPT_SPE_UNAVAIL] = 16, + [BOOKE_INTERRUPT_SPE_FP_DATA] = 17, + [BOOKE_INTERRUPT_SPE_FP_ROUND ] =18 };const unsigned char priority_exception[] = {
@@ -108,6 +114,9 @@ const unsigned char priority_exception[] = {BOOKE_INTERRUPT_EXTERNAL ,BOOKE_INTERRUPT_FIT ,BOOKE_INTERRUPT_DECREMENTER , +BOOKE_INTERRUPT_SPE_UNAVAIL , +BOOKE_INTERRUPT_SPE_FP_DATA , + BOOKE_INTERRUPT_SPE_FP_ROUND };/* TODO: use vcpu_printf() */
@@ -280,6 +289,9 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,break ;case BOOKE_INTERRUPT_FP_UNAVAIL : +case BOOKE_INTERRUPT_SPE_UNAVAIL : +case BOOKE_INTERRUPT_SPE_FP_DATA : +case BOOKE_INTERRUPT_SPE_FP_ROUND :kvmppc_queue_exception (vcpu, exit_nr); r =RESUME_GUEST ;break ;
arch/powerpc/kvm/booke_host.c +14 -6
@@ -27,9 +27,9 @@ unsigned long kvmppc_booke_handlers;static int kvmppc_booke_init (void ) { -unsigned long ivor[16 ]; +unsigned long ivor[BOOKE_INTERRUPT_NUM ];unsigned long max_ivor =0 ; -int i; +int i, valid_ivor;/* We install our own exception handlers by hijacking IVPR. IVPR must * be 16-bit aligned, so we need a 64KB allocation. */
@@ -42,6 +42,7 @@ static int kvmppc_booke_init(void)/* Copy our interrupt handlers to match host IVORs. That way we don't * have to swap the IVORs on every guest/host transition. */ +memset (ivor,0 ,sizeof (ivor)); ivor[0 ] =mfspr (SPRN_IVOR0 ); ivor[1 ] =mfspr (SPRN_IVOR1 ); ivor[2 ] =mfspr (SPRN_IVOR2 );
@@ -58,14 +59,21 @@ static int kvmppc_booke_init(void) ivor[13 ] =mfspr (SPRN_IVOR13 ); ivor[14 ] =mfspr (SPRN_IVOR14 ); ivor[15 ] =mfspr (SPRN_IVOR15 ); + ivor[32 ] =mfspr (SPRN_IVOR32 ); + ivor[33 ] =mfspr (SPRN_IVOR33 ); + ivor[34 ] =mfspr (SPRN_IVOR34 ); -for (i =0 ; i <16 ; i++) { +for (i =0 , valid_ivor =0 ; i <BOOKE_INTERRUPT_NUM ; i++) {if (ivor[i] > max_ivor) max_ivor = ivor[i]; -memcpy ((void *)kvmppc_booke_handlers + ivor[i], - kvmppc_handlers_start + i * kvmppc_handler_len, - kvmppc_handler_len); +if (ivor[i]) { +memcpy ((void *)kvmppc_booke_handlers + ivor[i], + kvmppc_handlers_start + + valid_ivor * kvmppc_handler_len, + kvmppc_handler_len); + valid_ivor++; + } }flush_icache_range (kvmppc_booke_handlers, kvmppc_booke_handlers + max_ivor + kvmppc_handler_len);
arch/powerpc/kvm/emulate.c +86 -2
142 lines not on this page · raw message
arch/powerpc/kvm/powerpc.c +4 -0
@@ -29,6 +29,7 @@#include <asm/kvm_ppc.h> #include <asm/tlbflush.h> +#include "powerpc.h" gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn) {
@@ -102,6 +103,8 @@ void kvm_arch_check_processor_compat(void *rtn)if (strcmp (cur_cpu_spec->platform,"ppc440" ) =0 ) r =0 ; +else if (strcmp (cur_cpu_spec->cpu_name,"e500v2" ) =0 ) + r =0 ;else r = -ENOTSUPP ;
@@ -230,6 +233,7 @@ static void kvmppc_decrementer_func(unsigned long data)int kvm_arch_vcpu_init (struct kvm_vcpu *vcpu) { +kvmppc_tlb_init (vcpu);setup_timer (&vcpu->arch.dec_timer, kvmppc_decrementer_func, (unsigned long )vcpu);
arch/powerpc/kvm/powerpc.h +4 -0
@@ -7,4 +7,8 @@#include "44x_tlb.h" #endif +#ifdef CONFIG_E500 +#include "e500_tlb.h" +#endif +#endif /* __KVM_POWERPC_POWERPC_H__ */
Signature · 1 line
1.5.4
Quoted 3 lines · Liu Yu
Any chance we could merge struct
kvm_vcpu_archfor both 44x and e500?
In the end we might end up needing
vcpu -> arch -> core
kvm things power arch core specific things
Hollis is working on better abstraction and restructuring code anyway so he might have a more detailed opinion ;-)
Quoted 16 lines
Signed-off-by Liu Yu <[email protected]>--- arch/powerpc/include/asm/kvm_asm.h | 7 ++- arch/powerpc/include/asm/kvm_host.h | 112 +++++++++++++++++++++++++++++++++++ arch/powerpc/kernel/asm-offsets.c | 9 +++ arch/powerpc/kvm/44x_tlb.h | 4 + arch/powerpc/kvm/Kconfig | 4 +- arch/powerpc/kvm/Makefile | 7 ++ arch/powerpc/kvm/booke_guest.c | 14 ++++- arch/powerpc/kvm/booke_host.c | 20 ++++-- arch/powerpc/kvm/emulate.c | 88 +++++++++++++++++++++++++++- arch/powerpc/kvm/powerpc.c | 4 + arch/powerpc/kvm/powerpc.h | 4 + 11 files changed, 261 insertions(+), 12 deletions(-)
[...]
Signature · 3 lines
Grüsse / regards, Christian Ehrhardt IBM Linux Technology Center, Open Virtualization
Quoted 13 lines
-----Original Message-----
From: Christian Ehrhardt [mailto:[email protected]]
Sent: Thursday, August 21, 2008 10:29 PM
To: Liu Yu
Cc: [email protected]
Subject: Re: [PATCH 4/4] add e500 support for kvmQuoted 1 line · Liu Yu
Any chance we could merge struct
kvm_vcpu_archfor both 44xand e500?
Quoted 2 lines
Quoted 6 lines
In the end we might end up needing
vcpu -> arch -> core
kvm things power arch core specific thingsHollis is working on better abstraction and restructuring code anyway so he might have a more detailed opinion ;-)
There is a saying "throw a sprat to catch a whale" :-)
Quoted 28 lines
Quoted 5 lines
Signed-off-by Liu Yu <[email protected]>--- arch/powerpc/include/asm/kvm_asm.h | 7 ++- arch/powerpc/include/asm/kvm_host.h | 112+++++++++++++++++++++++++++++++++++
Quoted 7 lines
arch/powerpc/kernel/asm-offsets.c | 9 +++ arch/powerpc/kvm/44x_tlb.h | 4 + arch/powerpc/kvm/Kconfig | 4 +- arch/powerpc/kvm/Makefile | 7 ++ arch/powerpc/kvm/booke_guest.c | 14 ++++- arch/powerpc/kvm/booke_host.c | 20 ++++-- arch/powerpc/kvm/emulate.c | 88+++++++++++++++++++++++++++-
Quoted 5 lines
arch/powerpc/kvm/powerpc.c | 4 + arch/powerpc/kvm/powerpc.h | 4 + 11 files changed, 261 insertions(+), 12 deletions(-)[...]
Signature · 3 lines
Grüsse / regards, Christian Ehrhardt IBM Linux Technology Center, Open Virtualization