PPC: EPR support when using KVM
cover PPC: EPR support when using KVM
This patch set implements the External PRoxy facility capability when running an e500 target with KVM.
Alexander Graf (3):
Update Linux kernel headers
openpic: export e500 epr enable into a ppc.c function
PPC: KVM: Add support for EPR with KVM
hw/openpic.c | 11 +++++------ hw/ppc.c | 17 +++++++++++++++++ hw/ppc.h | 2 ++ linux-headers/asm-powerpc/kvm.h | 6 +++++- linux-headers/linux/kvm.h | 27 +++++++++++++++++++++++++++ target-ppc/kvm.c | 21 +++++++++++++++++++++ target-ppc/kvm_ppc.h | 5 +++++ 7 files changed, 82 insertions(+), 7 deletions(-)
PATCH 1/3 Update Linux kernel headers
Based on kvm.git a843fac (next) plus dfdebc24 (master).
Signed-off-by Alexander Graf <[email protected]>
--- linux-headers/asm-powerpc/kvm.h | 6 +++++- linux-headers/linux/kvm.h | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletions(-)
linux-headers/asm-powerpc/kvm.h +5 -1
@@ -114,7 +114,10 @@ struct kvm_regs {/* Embedded Floating Point (SPE) -- IVOR32-34 if KVM_SREGS_E_IVOR */ #define KVM_SREGS_E_SPE (1 << 9) -/* External Proxy (EXP) -- EPR */ +/* +* DEPRECATED! USE ONE_REG FOR THIS ONE! +* External Proxy (EXP) -- EPR +*/ #define KVM_SREGS_EXP (1 << 10)/* External PID (E.PD) -- EPSC/EPLC */
@@ -412,5 +415,6 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_VPA_DTL (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84)#define KVM_REG_PPC_EPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85) +#define KVM_REG_PPC_EPR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x86)#endif /* __LINUX_KVM_POWERPC_H */
linux-headers/linux/kvm.h +27 -0
@@ -168,6 +168,8 @@ struct kvm_pit_config {#define KVM_EXIT_PAPR_HCALL 19#define KVM_EXIT_S390_UCONTROL 20#define KVM_EXIT_WATCHDOG 21 +#define KVM_EXIT_S390_TSCH 22 +#define KVM_EXIT_EPR 23/* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */
@@ -285,6 +287,19 @@ struct kvm_run {__u64 ret;__u64 args[9 ]; } papr_hcall; +/* KVM_EXIT_S390_TSCH */ +struct { +__u16 subchannel_id; +__u16 subchannel_nr; +__u32 io_int_parm; +__u32 io_int_word; +__u32 ipb; +__u8 dequeued; + } s390_tsch; +/* KVM_EXIT_EPR */ +struct { +__u32 epr; + } epr;/* Fix the size of the union. */ char padding[256 ]; };
@@ -397,10 +412,20 @@ struct kvm_s390_psw {#define KVM_S390_PROGRAM_INT 0xfffe0001u#define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u#define KVM_S390_RESTART 0xfffe0003u +#define KVM_S390_MCHK 0xfffe1000u#define KVM_S390_INT_VIRTIO 0xffff2603u#define KVM_S390_INT_SERVICE 0xffff2401u#define KVM_S390_INT_EMERGENCY 0xffff1201u#define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u +/* Anything below 0xfffe0000u is taken by INT_IO */ +#define KVM_S390_INT_IO (ai,cssid,ssid,schid) \ + (((schid)) | \ + ((ssid) << 16) | \ + ((cssid) << 18) | \ + ((ai) << 26)) +#define KVM_S390_INT_IO_MIN 0x00000000u +#define KVM_S390_INT_IO_MAX 0xfffdffffu +struct kvm_s390_interrupt {__u32 type;
@@ -635,6 +660,8 @@ struct kvm_ppc_smmu_info {#define KVM_CAP_IRQFD_RESAMPLE 82#define KVM_CAP_PPC_BOOKE_WATCHDOG 83#define KVM_CAP_PPC_HTAB_FD 84 +#define KVM_CAP_S390_CSS_SUPPORT 85 +#define KVM_CAP_PPC_EPR 86#ifdef KVM_CAP_IRQ_ROUTING
Signature · 1 line
1.6.0.2
PATCH 2/3 openpic: export e500 epr enable into a ppc.c function
In reply to Alexander GrafEnabling and disabling the EPR capability (mpic_proxy) is a system wide operation. As such, it belongs into the ppc.c file, since that's where PPC specific machine wide logic happens.
Signed-off-by Alexander Graf <[email protected]>
--- hw/openpic.c | 11 +++++------ hw/ppc.c | 11 +++++++++++ hw/ppc.h | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-)
hw/openpic.c +5 -6
@@ -40,6 +40,7 @@#include "sysbus.h" #include "pci/msi.h" #include "qemu/bitops.h" +#include "ppc.h" //#define DEBUG_OPENPIC
@@ -646,8 +647,7 @@ static inline void write_IRQreg_ivpr(OpenPICState *opp, int n_IRQ, uint32_t val)static void openpic_gcr_write (OpenPICState *opp,uint64_t val) { -CPUArchState *env; -int mpic_proxy =0 ; +bool mpic_proxy = false;if (val &GCR_RESET ) {openpic_reset (&opp->busdev.qdev);
@@ -659,11 +659,10 @@ static void openpic_gcr_write(OpenPICState *opp, uint64_t val)/* Set external proxy mode */ if ((val & opp->mpic_mode_mask) ==GCR_MODE_PROXY ) { - mpic_proxy =1 ; - } -for (env = first_cpu; env !=NULL ; env = env->next_cpu) { - env->mpic_proxy = mpic_proxy; + mpic_proxy = true; } + +ppce500_set_mpic_proxy (mpic_proxy); } static void openpic_gbl_write(void *opaque, hwaddr addr, uint64_t val,
hw/ppc.c +11 -0
@@ -428,6 +428,17 @@ void ppce500_irq_init(CPUPPCState *env) env->irq_inputs = (void **)qemu_allocate_irqs (&ppce500_set_irq, cpu,PPCE500_INPUT_NB ); } + +/* Enable or Disable the E500 EPR capability */ +void ppce500_set_mpic_proxy (bool enabled) +{ +CPUPPCState *env; + +for (env = first_cpu; env !=NULL ; env = env->next_cpu) { + env->mpic_proxy = enabled; + } +} +/*****************************************************************************/ /* PowerPC time base and decrementer emulation */
hw/ppc.h +2 -0
@@ -73,6 +73,8 @@ void ppc6xx_irq_init (CPUPPCState *env);void ppc970_irq_init (CPUPPCState *env);void ppcPOWER7_irq_init (CPUPPCState *env); +void ppce500_set_mpic_proxy (bool enabled); +/* PPC machines for OpenBIOS */ enum {ARCH_PREP =0 ,
Signature · 1 line
1.6.0.2
PATCH 3/3 PPC: KVM: Add support for EPR with KVM
In reply to Alexander GrafThis patch links KVM EPR support to the existing TCG support we have now.
Signed-off-by Alexander Graf <[email protected]>
--- hw/ppc.c | 6 ++++++ target-ppc/kvm.c | 21 +++++++++++++++++++++ target-ppc/kvm_ppc.h | 5 +++++ 3 files changed, 32 insertions(+), 0 deletions(-)
hw/ppc.c +6 -0
@@ -435,7 +435,13 @@ void ppce500_set_mpic_proxy(bool enabled)CPUPPCState *env;for (env = first_cpu; env !=NULL ; env = env->next_cpu) { +PowerPCCPU *cpu =ppc_env_get_cpu (env); +CPUState *cs =CPU (cpu); + env->mpic_proxy = enabled; +if (kvm_enabled ()) { +kvmppc_set_mpic_proxy (POWERPC_CPU (cs), enabled); + } } }
target-ppc/kvm.c +21 -0
@@ -846,6 +846,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) ret =0 ;break ;#endif +case KVM_EXIT_EPR : +dprintf ("handle epr\n" ); + run->epr.epr =ldl_phys (env->mpic_iack); + ret =0 ; +break ;default :fprintf (stderr,"KVM: unknown exit reason %d\n" , run->exit_reason); ret =-1 ;
@@ -1057,6 +1062,22 @@ void kvmppc_set_papr(PowerPCCPU *cpu) } } +void kvmppc_set_mpic_proxy (PowerPCCPU *cpu,int mpic_proxy) +{ +CPUPPCState *env = &cpu->env; +CPUState *cs =CPU (cpu); +struct kvm_enable_cap cap = {}; +int ret; + + cap.cap =KVM_CAP_PPC_EPR ; + cap.args[0 ] = mpic_proxy; + ret =kvm_vcpu_ioctl (cs,KVM_ENABLE_CAP , &cap); + +if (ret && mpic_proxy) { +cpu_abort (env,"This KVM version does not support EPR\n" ); + } +} +int kvmppc_smt_threads (void ) {return cap_ppc_smt ? cap_ppc_smt :1 ;
target-ppc/kvm_ppc.h +5 -0
@@ -25,6 +25,7 @@ int kvmppc_get_hasidle(CPUPPCState *env);int kvmppc_get_hypercall (CPUPPCState *env,uint8_t *buf,int buf_len);int kvmppc_set_interrupt (PowerPCCPU *cpu,int irq,int level);void kvmppc_set_papr (PowerPCCPU *cpu); +void kvmppc_set_mpic_proxy (PowerPCCPU *cpu,int mpic_proxy);int kvmppc_smt_threads (void );#ifndef CONFIG_USER_ONLY off_t kvmppc_alloc_rma (const char *name,MemoryRegion *sysmem);
@@ -81,6 +82,10 @@ static inline void kvmppc_set_papr(PowerPCCPU *cpu) { } +static inline void kvmppc_set_mpic_proxy (PowerPCCPU *cpu,int mpic_proxy) +{ +} +static inline int kvmppc_smt_threads (void ) {return 1 ;
Signature · 1 line
1.6.0.2