KVM: PPC: Book3S: Add MMIO emulation for FP and VSX instructions
Subsystems (3)
PATCH 1/1 KVM: PPC: Book3S: Add MMIO emulation for FP and VSX instructions
From: Bin Lu <[email protected]>
This patch provides the MMIO load/store emulation for instructions of 'double & vector unsigned char & vector signed char & vector unsigned short & vector signed short & vector unsigned int & vector signed int & vector double '.
The instructions that this adds emulation for are:
- ldx, ldux, lwax,
- lfs, lfsx, lfsu, lfsux, lfd, lfdx, lfdu, lfdux,
- stfs, stfsx, stfsu, stfsux, stfd, stfdx, stfdu, stfdux, stfiwx,
- lxsdx, lxsspx, lxsiwax, lxsiwzx, lxvd2x, lxvw4x, lxvdsx,
- stxsdx, stxsspx, stxsiwx, stxvd2x, stxvw4x
[[email protected] - some cleanups, fixes and rework]
--- arch/powerpc/include/asm/disassemble.h | 5 + arch/powerpc/include/asm/kvm_host.h | 23 +++ arch/powerpc/include/asm/kvm_ppc.h | 7 + arch/powerpc/include/asm/ppc-opcode.h | 50 +++++ arch/powerpc/kvm/Makefile | 3 +- arch/powerpc/kvm/emulate_loadstore.c | 326 ++++++++++++++++++++++++++++++++- arch/powerpc/kvm/powerpc.c | 298 +++++++++++++++++++++++++++++- 7 files changed, 701 insertions(+), 11 deletions(-)
arch/powerpc/include/asm/disassemble.h +5 -0
@@ -87,6 +87,11 @@ static inline unsigned int get_oc(u32 inst)return (inst >>11 ) &0x7fff ; } +static inline unsigned int get_tx_or_sx (u32 inst) +{ +return (inst) &0x1 ; +} +#define IS_XFORM (inst) (get_op(inst) = 31)#define IS_DSFORM (inst) (get_op(inst) >= 56)
arch/powerpc/include/asm/kvm_host.h +23 -0
@@ -441,6 +441,11 @@ struct mmio_hpte_cache {unsigned int index; }; +#define KVMPPC_VSX_COPY_NONE 0 +#define KVMPPC_VSX_COPY_WORD 1 +#define KVMPPC_VSX_COPY_DWORD 2 +#define KVMPPC_VSX_COPY_DWORD_LOAD_DUMP 3 +struct openpic ;struct kvm_vcpu_arch {
@@ -644,6 +649,21 @@ struct kvm_vcpu_arch {u8 io_gpr;/* GPR used as IO source/target */ u8 mmio_host_swabbed;u8 mmio_sign_extend; +/* conversion between single and double precision */ +u8 mmio_sp64_extend; +/* +* Number of simulations for vsx. +* If we use 2*8bytes to simulate 1*16bytes, +* then the number should be 2 and +* mmio_vsx_copy_type=KVMPPC_VSX_COPY_DWORD. +* If we use 4*4bytes to simulate 1*16bytes, +* the number should be 4 and +* mmio_vsx_copy_type=KVMPPC_VSX_COPY_WORD. +*/ +u8 mmio_vsx_copy_nums; +u8 mmio_vsx_offset; +u8 mmio_vsx_copy_type; +u8 mmio_vsx_tx_sx_enabled;u8 osi_needed;u8 osi_enabled;u8 papr_enabled;
@@ -732,6 +752,8 @@ struct kvm_vcpu_arch { };#define VCPU_FPR (vcpu, i) (vcpu)->arch.fp.fpr[i][TS_FPROFFSET] +#define VCPU_VSX_FPR (vcpu, i, j) ((vcpu)->arch.fp.fpr[i][j]) +#define VCPU_VSX_VR (vcpu, i) ((vcpu)->arch.vr.vr[i])/* Values for vcpu->arch.state */ #define KVMPPC_VCPU_NOTREADY 0
@@ -745,6 +767,7 @@ struct kvm_vcpu_arch {#define KVM_MMIO_REG_FPR 0x0020#define KVM_MMIO_REG_QPR 0x0040#define KVM_MMIO_REG_FQPR 0x0060 +#define KVM_MMIO_REG_VSX 0x0080#define __KVM_HAVE_ARCH_WQP#define __KVM_HAVE_CREATE_DEVICE
arch/powerpc/include/asm/kvm_ppc.h +7 -0
@@ -78,9 +78,15 @@ extern int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,extern int kvmppc_handle_loads (struct kvm_run *run,struct kvm_vcpu *vcpu,unsigned int rt,unsigned int bytes,int is_default_endian); +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_store (struct kvm_run *run,struct kvm_vcpu *vcpu,u64 val,unsigned int bytes,int is_default_endian); +extern int kvmppc_handle_vsx_store (struct kvm_run *run,struct kvm_vcpu *vcpu, +int rs,unsigned int bytes, +int is_default_endian);extern int kvmppc_load_last_inst (struct kvm_vcpu *vcpu,enum instruction_type type,u32 *inst);
@@ -240,6 +246,7 @@ union kvmppc_one_reg {u64 dval;vector128 vval;u64 vsxval[2 ]; +u32 vsx32val[4 ];struct {u64 addr;u64 length;
arch/powerpc/include/asm/ppc-opcode.h +50 -0
79 lines not on this page · raw message
arch/powerpc/kvm/Makefile +1 -2
@@ -16,7 +16,7 @@ CFLAGS_e500_mmu_host.o := -I. CFLAGS_emulate.o := -I. CFLAGS_emulate_loadstore.o := -I. -common-objs-y += powerpc.o emulate_loadstore.o +common-objs-y += powerpc.o emulate_loadstore.o fpu.o obj-$(CONFIG_KVM_EXIT_TIMING) += timing.o obj-$(CONFIG_KVM_BOOK3S_HANDLER) += book3s_exports.o
@@ -101,7 +101,6 @@ kvm-objs-$(CONFIG_KVM_BOOK3S_64) := $(kvm-book3s_64-module-objs) kvm-book3s_32-objs := \ $(common-objs-y) \ emulate.o \ - fpu.o \ book3s_paired_singles.o \ book3s.o \ book3s_pr.o \
arch/powerpc/kvm/emulate_loadstore.c +324 -1
358 lines not on this page · raw message
arch/powerpc/kvm/powerpc.c +288 -8
380 lines not on this page · raw message
Signature · 1 line
2.7.4