Implements MMIO emulation for lvx/stvx instructions
Subsystems (2)
cover Implements MMIO emulation for lvx/stvx instructions
This patch implements MMIO emulation for two instructions: lvx and stvx.
Thanks.
Jose Ricardo Ziviani (1):
KVM: PPC: Book3S: Add MMIO emulation for VMX instructions
arch/powerpc/include/asm/kvm_host.h | 2 + arch/powerpc/include/asm/kvm_ppc.h | 4 + arch/powerpc/include/asm/ppc-opcode.h | 6 ++ arch/powerpc/kvm/emulate_loadstore.c | 32 +++++++ arch/powerpc/kvm/powerpc.c | 162 ++++++++++++++++++++++++++++++---- 5 files changed, 189 insertions(+), 17 deletions(-)
Signature · 1 line
2.14.1
PATCH RESEND 1/1 KVM: PPC: Book3S: Add MMIO emulation for VMX instructions
This patch provides the MMIO load/store vector indexed X-Form emulation.
Instructions implemented: lvx, stvx
--- arch/powerpc/include/asm/kvm_host.h | 2 + arch/powerpc/include/asm/kvm_ppc.h | 4 + arch/powerpc/include/asm/ppc-opcode.h | 6 ++ arch/powerpc/kvm/emulate_loadstore.c | 32 +++++++ arch/powerpc/kvm/powerpc.c | 162 ++++++++++++++++++++++++++++++---- 5 files changed, 189 insertions(+), 17 deletions(-)
arch/powerpc/include/asm/kvm_host.h +2 -0
@@ -690,6 +690,7 @@ struct kvm_vcpu_arch {u8 mmio_vsx_offset;u8 mmio_vsx_copy_type;u8 mmio_vsx_tx_sx_enabled; +u8 mmio_vmx_copy_nums;u8 osi_needed;u8 osi_enabled;u8 papr_enabled;
@@ -800,6 +801,7 @@ struct kvm_vcpu_arch {#define KVM_MMIO_REG_QPR 0x0040#define KVM_MMIO_REG_FQPR 0x0060#define KVM_MMIO_REG_VSX 0x0080 +#define KVM_MMIO_REG_VMX 0x00a0#define __KVM_HAVE_ARCH_WQP#define __KVM_HAVE_CREATE_DEVICE
arch/powerpc/include/asm/kvm_ppc.h +4 -0
@@ -81,6 +81,10 @@ extern int kvmppc_handle_loads(struct kvm_run *run, struct kvm_vcpu *vcpu,extern int kvmppc_handle_vsx_load (struct kvm_run *run,struct kvm_vcpu *vcpu,unsigned int rt,unsigned int bytes,int is_default_endian,int mmio_sign_extend); +extern int kvmppc_handle_load128_by2x64 (struct kvm_run *run, +struct kvm_vcpu *vcpu,unsigned int rt,int is_default_endian); +extern int kvmppc_handle_store128_by2x64 (struct kvm_run *run, +struct kvm_vcpu *vcpu,unsigned int rs,int is_default_endian);extern int kvmppc_handle_store (struct kvm_run *run,struct kvm_vcpu *vcpu,u64 val,unsigned int bytes,int is_default_endian);
arch/powerpc/include/asm/ppc-opcode.h +6 -0
@@ -156,6 +156,12 @@#define OP_31_XOP_LFDX 599#define OP_31_XOP_LFDUX 631 +/* VMX Vector Load Instructions */ +#define OP_31_XOP_LVX 103 + +/* VMX Vector Store Instructions */ +#define OP_31_XOP_STVX 231 +#define OP_LWZ 32#define OP_STFS 52#define OP_STFSU 53
arch/powerpc/kvm/emulate_loadstore.c +32 -0
@@ -58,6 +58,18 @@ static bool kvmppc_check_vsx_disabled(struct kvm_vcpu *vcpu) }#endif /* CONFIG_VSX */ +#ifdef CONFIG_ALTIVEC +static bool kvmppc_check_altivec_disabled (struct kvm_vcpu *vcpu) +{ +if (!(kvmppc_get_msr (vcpu) &MSR_VEC )) { +kvmppc_core_queue_vec_unavail (vcpu); +return true; + } + +return false; +} +#endif /* CONFIG_ALTIVEC */ +/* * XXX to do: * lfiwax, lfiwzx
@@ -98,6 +110,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) vcpu->arch.mmio_vsx_copy_type =KVMPPC_VSX_COPY_NONE ; vcpu->arch.mmio_sp64_extend =0 ; vcpu->arch.mmio_sign_extend =0 ; + vcpu->arch.mmio_vmx_copy_nums =0 ;switch (get_op (inst)) {case 31 :
@@ -459,6 +472,25 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) rs, 4, 1);break ;#endif /* CONFIG_VSX */ + +#ifdef CONFIG_ALTIVEC +case OP_31_XOP_LVX : +if (kvmppc_check_altivec_disabled (vcpu)) +return EMULATE_DONE ; + vcpu->arch.mmio_vmx_copy_nums =2 ; + emulated =kvmppc_handle_load128_by2x64 (run, vcpu, +KVM_MMIO_REG_VMX |rt,1 ); +break ; + +case OP_31_XOP_STVX : +if (kvmppc_check_altivec_disabled (vcpu)) +return EMULATE_DONE ; + vcpu->arch.mmio_vmx_copy_nums =2 ; + emulated =kvmppc_handle_store128_by2x64 (run, vcpu, + rs,1 ); +break ; +#endif /* CONFIG_ALTIVEC */ +default : emulated =EMULATE_FAIL ;break ;
arch/powerpc/kvm/powerpc.c +145 -17
192 lines not on this page · raw message
Signature · 1 line
2.14.1
Michael Ellerman
reviewerRe: [PATCH RESEND 1/1] KVM: PPC: Book3S: Add MMIO emulation for VMX instructions
Quoted 5 lines · Jose Ricardo Ziviani
This patch provides the MMIO load/store vector indexed X-Form emulation.
Instructions implemented: lvx, stvx
Quoted 8 lines
Signed-off-by Jose Ricardo Ziviani <[email protected]>--- arch/powerpc/include/asm/kvm_host.h | 2 + arch/powerpc/include/asm/kvm_ppc.h | 4 + arch/powerpc/include/asm/ppc-opcode.h | 6 ++ arch/powerpc/kvm/emulate_loadstore.c | 32 +++++++ arch/powerpc/kvm/powerpc.c | 162 ++++++++++++++++++++++++++++++---- 5 files changed, 189 insertions(+), 17 deletions(-)
KVM patches should be Cc'ed to [email protected], that way Paul will see them in his patchwork at:
http://patchwork.ozlabs.org/project/kvm-ppc/list/
cheers