aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2016-06-15 14:29:47 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2016-06-15 17:58:17 -0400
commit258f3a2ea93ff7e322006c716cedc4fa3d861453 (patch)
tree06792df7de3f877db5af2850c454f36a18d11cec /arch/mips/include
parentd5cd26bcfc881f5443d510e3acd40b30d7b7d0df (diff)
MIPS: KVM: Convert emulation to use asm/inst.h
Convert various MIPS KVM guest instruction emulation functions to decode instructions (and encode translations) using the union mips_instruction and related enumerations in asm/inst.h rather than #defines and hardcoded values. Signed-off-by: James Hogan <james.hogan@imgtec.com> Acked-by: Ralf Baechle <ralf@linux-mips.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krčmář <rkrcmar@redhat.com> Cc: linux-mips@linux-mips.org Cc: kvm@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/mips/include')
-rw-r--r--arch/mips/include/asm/kvm_host.h22
-rw-r--r--arch/mips/include/uapi/asm/inst.h35
2 files changed, 47 insertions, 10 deletions
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
index b8cb74270746..1e002136f514 100644
--- a/arch/mips/include/asm/kvm_host.h
+++ b/arch/mips/include/asm/kvm_host.h
@@ -19,6 +19,7 @@
19#include <linux/threads.h> 19#include <linux/threads.h>
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21 21
22#include <asm/inst.h>
22#include <asm/mipsregs.h> 23#include <asm/mipsregs.h>
23 24
24/* MIPS KVM register ids */ 25/* MIPS KVM register ids */
@@ -733,21 +734,21 @@ enum emulation_result kvm_mips_check_privilege(u32 cause,
733 struct kvm_run *run, 734 struct kvm_run *run,
734 struct kvm_vcpu *vcpu); 735 struct kvm_vcpu *vcpu);
735 736
736enum emulation_result kvm_mips_emulate_cache(u32 inst, 737enum emulation_result kvm_mips_emulate_cache(union mips_instruction inst,
737 u32 *opc, 738 u32 *opc,
738 u32 cause, 739 u32 cause,
739 struct kvm_run *run, 740 struct kvm_run *run,
740 struct kvm_vcpu *vcpu); 741 struct kvm_vcpu *vcpu);
741enum emulation_result kvm_mips_emulate_CP0(u32 inst, 742enum emulation_result kvm_mips_emulate_CP0(union mips_instruction inst,
742 u32 *opc, 743 u32 *opc,
743 u32 cause, 744 u32 cause,
744 struct kvm_run *run, 745 struct kvm_run *run,
745 struct kvm_vcpu *vcpu); 746 struct kvm_vcpu *vcpu);
746enum emulation_result kvm_mips_emulate_store(u32 inst, 747enum emulation_result kvm_mips_emulate_store(union mips_instruction inst,
747 u32 cause, 748 u32 cause,
748 struct kvm_run *run, 749 struct kvm_run *run,
749 struct kvm_vcpu *vcpu); 750 struct kvm_vcpu *vcpu);
750enum emulation_result kvm_mips_emulate_load(u32 inst, 751enum emulation_result kvm_mips_emulate_load(union mips_instruction inst,
751 u32 cause, 752 u32 cause,
752 struct kvm_run *run, 753 struct kvm_run *run,
753 struct kvm_vcpu *vcpu); 754 struct kvm_vcpu *vcpu);
@@ -758,11 +759,14 @@ unsigned int kvm_mips_config4_wrmask(struct kvm_vcpu *vcpu);
758unsigned int kvm_mips_config5_wrmask(struct kvm_vcpu *vcpu); 759unsigned int kvm_mips_config5_wrmask(struct kvm_vcpu *vcpu);
759 760
760/* Dynamic binary translation */ 761/* Dynamic binary translation */
761extern int kvm_mips_trans_cache_index(u32 inst, u32 *opc, 762extern int kvm_mips_trans_cache_index(union mips_instruction inst,
762 struct kvm_vcpu *vcpu); 763 u32 *opc, struct kvm_vcpu *vcpu);
763extern int kvm_mips_trans_cache_va(u32 inst, u32 *opc, struct kvm_vcpu *vcpu); 764extern int kvm_mips_trans_cache_va(union mips_instruction inst, u32 *opc,
764extern int kvm_mips_trans_mfc0(u32 inst, u32 *opc, struct kvm_vcpu *vcpu); 765 struct kvm_vcpu *vcpu);
765extern int kvm_mips_trans_mtc0(u32 inst, u32 *opc, struct kvm_vcpu *vcpu); 766extern int kvm_mips_trans_mfc0(union mips_instruction inst, u32 *opc,
767 struct kvm_vcpu *vcpu);
768extern int kvm_mips_trans_mtc0(union mips_instruction inst, u32 *opc,
769 struct kvm_vcpu *vcpu);
766 770
767/* Misc */ 771/* Misc */
768extern void kvm_mips_dump_stats(struct kvm_vcpu *vcpu); 772extern void kvm_mips_dump_stats(struct kvm_vcpu *vcpu);
diff --git a/arch/mips/include/uapi/asm/inst.h b/arch/mips/include/uapi/asm/inst.h
index 8051f9aa1379..a1ebf973725c 100644
--- a/arch/mips/include/uapi/asm/inst.h
+++ b/arch/mips/include/uapi/asm/inst.h
@@ -103,7 +103,7 @@ enum rt_op {
103 bltzal_op, bgezal_op, bltzall_op, bgezall_op, 103 bltzal_op, bgezal_op, bltzall_op, bgezall_op,
104 rt_op_0x14, rt_op_0x15, rt_op_0x16, rt_op_0x17, 104 rt_op_0x14, rt_op_0x15, rt_op_0x16, rt_op_0x17,
105 rt_op_0x18, rt_op_0x19, rt_op_0x1a, rt_op_0x1b, 105 rt_op_0x18, rt_op_0x19, rt_op_0x1a, rt_op_0x1b,
106 bposge32_op, rt_op_0x1d, rt_op_0x1e, rt_op_0x1f 106 bposge32_op, rt_op_0x1d, rt_op_0x1e, synci_op
107}; 107};
108 108
109/* 109/*
@@ -586,6 +586,36 @@ struct r_format { /* Register format */
586 ;)))))) 586 ;))))))
587}; 587};
588 588
589struct c0r_format { /* C0 register format */
590 __BITFIELD_FIELD(unsigned int opcode : 6,
591 __BITFIELD_FIELD(unsigned int rs : 5,
592 __BITFIELD_FIELD(unsigned int rt : 5,
593 __BITFIELD_FIELD(unsigned int rd : 5,
594 __BITFIELD_FIELD(unsigned int z: 8,
595 __BITFIELD_FIELD(unsigned int sel : 3,
596 ;))))))
597};
598
599struct mfmc0_format { /* MFMC0 register format */
600 __BITFIELD_FIELD(unsigned int opcode : 6,
601 __BITFIELD_FIELD(unsigned int rs : 5,
602 __BITFIELD_FIELD(unsigned int rt : 5,
603 __BITFIELD_FIELD(unsigned int rd : 5,
604 __BITFIELD_FIELD(unsigned int re : 5,
605 __BITFIELD_FIELD(unsigned int sc : 1,
606 __BITFIELD_FIELD(unsigned int : 2,
607 __BITFIELD_FIELD(unsigned int sel : 3,
608 ;))))))))
609};
610
611struct co_format { /* C0 CO format */
612 __BITFIELD_FIELD(unsigned int opcode : 6,
613 __BITFIELD_FIELD(unsigned int co : 1,
614 __BITFIELD_FIELD(unsigned int code : 19,
615 __BITFIELD_FIELD(unsigned int func : 6,
616 ;))))
617};
618
589struct p_format { /* Performance counter format (R10000) */ 619struct p_format { /* Performance counter format (R10000) */
590 __BITFIELD_FIELD(unsigned int opcode : 6, 620 __BITFIELD_FIELD(unsigned int opcode : 6,
591 __BITFIELD_FIELD(unsigned int rs : 5, 621 __BITFIELD_FIELD(unsigned int rs : 5,
@@ -937,6 +967,9 @@ union mips_instruction {
937 struct u_format u_format; 967 struct u_format u_format;
938 struct c_format c_format; 968 struct c_format c_format;
939 struct r_format r_format; 969 struct r_format r_format;
970 struct c0r_format c0r_format;
971 struct mfmc0_format mfmc0_format;
972 struct co_format co_format;
940 struct p_format p_format; 973 struct p_format p_format;
941 struct f_format f_format; 974 struct f_format f_format;
942 struct ma_format ma_format; 975 struct ma_format ma_format;