aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeng-Cheng Zhu <dengcheng.zhu@imgtec.com>2014-06-26 15:11:36 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-06-30 10:52:02 -0400
commitd98403a525fe1648c516f33e2bf674d277d69135 (patch)
tree2cb239cc4708829314830a32b7747c2ecb3455cd
parent6ad78a5c75c5bcfdac4551f7d09b777b3dc3c19c (diff)
MIPS: KVM: Simplify functions by removing redundancy
No logic changes inside. Reviewed-by: James Hogan <james.hogan@imgtec.com> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/mips/include/asm/kvm_host.h2
-rw-r--r--arch/mips/kvm/kvm_mips.c18
-rw-r--r--arch/mips/kvm/kvm_mips_commpage.c2
-rw-r--r--arch/mips/kvm/kvm_mips_emul.c34
-rw-r--r--arch/mips/kvm/kvm_mips_stats.c4
5 files changed, 17 insertions, 43 deletions
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
index 3f813f295134..7a3fc67bd7f9 100644
--- a/arch/mips/include/asm/kvm_host.h
+++ b/arch/mips/include/asm/kvm_host.h
@@ -764,7 +764,7 @@ extern int kvm_mips_trans_mtc0(uint32_t inst, uint32_t *opc,
764 struct kvm_vcpu *vcpu); 764 struct kvm_vcpu *vcpu);
765 765
766/* Misc */ 766/* Misc */
767extern int kvm_mips_dump_stats(struct kvm_vcpu *vcpu); 767extern void kvm_mips_dump_stats(struct kvm_vcpu *vcpu);
768extern unsigned long kvm_mips_get_ramsize(struct kvm *kvm); 768extern unsigned long kvm_mips_get_ramsize(struct kvm *kvm);
769 769
770 770
diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c
index 330b3af701a6..289b4d2ae45c 100644
--- a/arch/mips/kvm/kvm_mips.c
+++ b/arch/mips/kvm/kvm_mips.c
@@ -97,9 +97,7 @@ void kvm_arch_hardware_unsetup(void)
97 97
98void kvm_arch_check_processor_compat(void *rtn) 98void kvm_arch_check_processor_compat(void *rtn)
99{ 99{
100 int *r = (int *)rtn; 100 *(int *)rtn = 0;
101 *r = 0;
102 return;
103} 101}
104 102
105static void kvm_mips_init_tlbs(struct kvm *kvm) 103static void kvm_mips_init_tlbs(struct kvm *kvm)
@@ -225,7 +223,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
225 enum kvm_mr_change change) 223 enum kvm_mr_change change)
226{ 224{
227 unsigned long npages = 0; 225 unsigned long npages = 0;
228 int i, err = 0; 226 int i;
229 227
230 kvm_debug("%s: kvm: %p slot: %d, GPA: %llx, size: %llx, QVA: %llx\n", 228 kvm_debug("%s: kvm: %p slot: %d, GPA: %llx, size: %llx, QVA: %llx\n",
231 __func__, kvm, mem->slot, mem->guest_phys_addr, 229 __func__, kvm, mem->slot, mem->guest_phys_addr,
@@ -243,8 +241,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
243 241
244 if (!kvm->arch.guest_pmap) { 242 if (!kvm->arch.guest_pmap) {
245 kvm_err("Failed to allocate guest PMAP"); 243 kvm_err("Failed to allocate guest PMAP");
246 err = -ENOMEM; 244 return;
247 goto out;
248 } 245 }
249 246
250 kvm_debug("Allocated space for Guest PMAP Table (%ld pages) @ %p\n", 247 kvm_debug("Allocated space for Guest PMAP Table (%ld pages) @ %p\n",
@@ -255,8 +252,6 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
255 kvm->arch.guest_pmap[i] = KVM_INVALID_PAGE; 252 kvm->arch.guest_pmap[i] = KVM_INVALID_PAGE;
256 } 253 }
257 } 254 }
258out:
259 return;
260} 255}
261 256
262void kvm_arch_flush_shadow_all(struct kvm *kvm) 257void kvm_arch_flush_shadow_all(struct kvm *kvm)
@@ -845,16 +840,12 @@ long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
845 840
846int kvm_arch_init(void *opaque) 841int kvm_arch_init(void *opaque)
847{ 842{
848 int ret;
849
850 if (kvm_mips_callbacks) { 843 if (kvm_mips_callbacks) {
851 kvm_err("kvm: module already exists\n"); 844 kvm_err("kvm: module already exists\n");
852 return -EEXIST; 845 return -EEXIST;
853 } 846 }
854 847
855 ret = kvm_mips_emulation_init(&kvm_mips_callbacks); 848 return kvm_mips_emulation_init(&kvm_mips_callbacks);
856
857 return ret;
858} 849}
859 850
860void kvm_arch_exit(void) 851void kvm_arch_exit(void)
@@ -1008,7 +999,6 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
1008 999
1009void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) 1000void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
1010{ 1001{
1011 return;
1012} 1002}
1013 1003
1014int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, 1004int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
diff --git a/arch/mips/kvm/kvm_mips_commpage.c b/arch/mips/kvm/kvm_mips_commpage.c
index ab7096ec0666..4b5612b34fef 100644
--- a/arch/mips/kvm/kvm_mips_commpage.c
+++ b/arch/mips/kvm/kvm_mips_commpage.c
@@ -33,6 +33,4 @@ void kvm_mips_commpage_init(struct kvm_vcpu *vcpu)
33 /* Specific init values for fields */ 33 /* Specific init values for fields */
34 vcpu->arch.cop0 = &page->cop0; 34 vcpu->arch.cop0 = &page->cop0;
35 memset(vcpu->arch.cop0, 0, sizeof(struct mips_coproc)); 35 memset(vcpu->arch.cop0, 0, sizeof(struct mips_coproc));
36
37 return;
38} 36}
diff --git a/arch/mips/kvm/kvm_mips_emul.c b/arch/mips/kvm/kvm_mips_emul.c
index bdd1421b78fc..f9b4f0fa425d 100644
--- a/arch/mips/kvm/kvm_mips_emul.c
+++ b/arch/mips/kvm/kvm_mips_emul.c
@@ -761,8 +761,6 @@ enum emulation_result kvm_mips_emul_eret(struct kvm_vcpu *vcpu)
761 761
762enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu) 762enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu)
763{ 763{
764 enum emulation_result er = EMULATE_DONE;
765
766 kvm_debug("[%#lx] !!!WAIT!!! (%#lx)\n", vcpu->arch.pc, 764 kvm_debug("[%#lx] !!!WAIT!!! (%#lx)\n", vcpu->arch.pc,
767 vcpu->arch.pending_exceptions); 765 vcpu->arch.pending_exceptions);
768 766
@@ -782,7 +780,7 @@ enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu)
782 } 780 }
783 } 781 }
784 782
785 return er; 783 return EMULATE_DONE;
786} 784}
787 785
788/* 786/*
@@ -792,11 +790,10 @@ enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu)
792enum emulation_result kvm_mips_emul_tlbr(struct kvm_vcpu *vcpu) 790enum emulation_result kvm_mips_emul_tlbr(struct kvm_vcpu *vcpu)
793{ 791{
794 struct mips_coproc *cop0 = vcpu->arch.cop0; 792 struct mips_coproc *cop0 = vcpu->arch.cop0;
795 enum emulation_result er = EMULATE_FAIL;
796 uint32_t pc = vcpu->arch.pc; 793 uint32_t pc = vcpu->arch.pc;
797 794
798 kvm_err("[%#x] COP0_TLBR [%ld]\n", pc, kvm_read_c0_guest_index(cop0)); 795 kvm_err("[%#x] COP0_TLBR [%ld]\n", pc, kvm_read_c0_guest_index(cop0));
799 return er; 796 return EMULATE_FAIL;
800} 797}
801 798
802/* Write Guest TLB Entry @ Index */ 799/* Write Guest TLB Entry @ Index */
@@ -804,7 +801,6 @@ enum emulation_result kvm_mips_emul_tlbwi(struct kvm_vcpu *vcpu)
804{ 801{
805 struct mips_coproc *cop0 = vcpu->arch.cop0; 802 struct mips_coproc *cop0 = vcpu->arch.cop0;
806 int index = kvm_read_c0_guest_index(cop0); 803 int index = kvm_read_c0_guest_index(cop0);
807 enum emulation_result er = EMULATE_DONE;
808 struct kvm_mips_tlb *tlb = NULL; 804 struct kvm_mips_tlb *tlb = NULL;
809 uint32_t pc = vcpu->arch.pc; 805 uint32_t pc = vcpu->arch.pc;
810 806
@@ -836,14 +832,13 @@ enum emulation_result kvm_mips_emul_tlbwi(struct kvm_vcpu *vcpu)
836 kvm_read_c0_guest_entrylo1(cop0), 832 kvm_read_c0_guest_entrylo1(cop0),
837 kvm_read_c0_guest_pagemask(cop0)); 833 kvm_read_c0_guest_pagemask(cop0));
838 834
839 return er; 835 return EMULATE_DONE;
840} 836}
841 837
842/* Write Guest TLB Entry @ Random Index */ 838/* Write Guest TLB Entry @ Random Index */
843enum emulation_result kvm_mips_emul_tlbwr(struct kvm_vcpu *vcpu) 839enum emulation_result kvm_mips_emul_tlbwr(struct kvm_vcpu *vcpu)
844{ 840{
845 struct mips_coproc *cop0 = vcpu->arch.cop0; 841 struct mips_coproc *cop0 = vcpu->arch.cop0;
846 enum emulation_result er = EMULATE_DONE;
847 struct kvm_mips_tlb *tlb = NULL; 842 struct kvm_mips_tlb *tlb = NULL;
848 uint32_t pc = vcpu->arch.pc; 843 uint32_t pc = vcpu->arch.pc;
849 int index; 844 int index;
@@ -874,14 +869,13 @@ enum emulation_result kvm_mips_emul_tlbwr(struct kvm_vcpu *vcpu)
874 kvm_read_c0_guest_entrylo0(cop0), 869 kvm_read_c0_guest_entrylo0(cop0),
875 kvm_read_c0_guest_entrylo1(cop0)); 870 kvm_read_c0_guest_entrylo1(cop0));
876 871
877 return er; 872 return EMULATE_DONE;
878} 873}
879 874
880enum emulation_result kvm_mips_emul_tlbp(struct kvm_vcpu *vcpu) 875enum emulation_result kvm_mips_emul_tlbp(struct kvm_vcpu *vcpu)
881{ 876{
882 struct mips_coproc *cop0 = vcpu->arch.cop0; 877 struct mips_coproc *cop0 = vcpu->arch.cop0;
883 long entryhi = kvm_read_c0_guest_entryhi(cop0); 878 long entryhi = kvm_read_c0_guest_entryhi(cop0);
884 enum emulation_result er = EMULATE_DONE;
885 uint32_t pc = vcpu->arch.pc; 879 uint32_t pc = vcpu->arch.pc;
886 int index = -1; 880 int index = -1;
887 881
@@ -892,7 +886,7 @@ enum emulation_result kvm_mips_emul_tlbp(struct kvm_vcpu *vcpu)
892 kvm_debug("[%#x] COP0_TLBP (entryhi: %#lx), index: %d\n", pc, entryhi, 886 kvm_debug("[%#x] COP0_TLBP (entryhi: %#lx), index: %d\n", pc, entryhi,
893 index); 887 index);
894 888
895 return er; 889 return EMULATE_DONE;
896} 890}
897 891
898enum emulation_result kvm_mips_emulate_CP0(uint32_t inst, uint32_t *opc, 892enum emulation_result kvm_mips_emulate_CP0(uint32_t inst, uint32_t *opc,
@@ -1638,7 +1632,6 @@ enum emulation_result kvm_mips_emulate_tlbmiss_ld(unsigned long cause,
1638{ 1632{
1639 struct mips_coproc *cop0 = vcpu->arch.cop0; 1633 struct mips_coproc *cop0 = vcpu->arch.cop0;
1640 struct kvm_vcpu_arch *arch = &vcpu->arch; 1634 struct kvm_vcpu_arch *arch = &vcpu->arch;
1641 enum emulation_result er = EMULATE_DONE;
1642 unsigned long entryhi = (vcpu->arch. host_cp0_badvaddr & VPN2_MASK) | 1635 unsigned long entryhi = (vcpu->arch. host_cp0_badvaddr & VPN2_MASK) |
1643 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1636 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK);
1644 1637
@@ -1675,7 +1668,7 @@ enum emulation_result kvm_mips_emulate_tlbmiss_ld(unsigned long cause,
1675 /* Blow away the shadow host TLBs */ 1668 /* Blow away the shadow host TLBs */
1676 kvm_mips_flush_host_tlb(1); 1669 kvm_mips_flush_host_tlb(1);
1677 1670
1678 return er; 1671 return EMULATE_DONE;
1679} 1672}
1680 1673
1681enum emulation_result kvm_mips_emulate_tlbinv_ld(unsigned long cause, 1674enum emulation_result kvm_mips_emulate_tlbinv_ld(unsigned long cause,
@@ -1685,7 +1678,6 @@ enum emulation_result kvm_mips_emulate_tlbinv_ld(unsigned long cause,
1685{ 1678{
1686 struct mips_coproc *cop0 = vcpu->arch.cop0; 1679 struct mips_coproc *cop0 = vcpu->arch.cop0;
1687 struct kvm_vcpu_arch *arch = &vcpu->arch; 1680 struct kvm_vcpu_arch *arch = &vcpu->arch;
1688 enum emulation_result er = EMULATE_DONE;
1689 unsigned long entryhi = 1681 unsigned long entryhi =
1690 (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | 1682 (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) |
1691 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1683 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK);
@@ -1722,7 +1714,7 @@ enum emulation_result kvm_mips_emulate_tlbinv_ld(unsigned long cause,
1722 /* Blow away the shadow host TLBs */ 1714 /* Blow away the shadow host TLBs */
1723 kvm_mips_flush_host_tlb(1); 1715 kvm_mips_flush_host_tlb(1);
1724 1716
1725 return er; 1717 return EMULATE_DONE;
1726} 1718}
1727 1719
1728enum emulation_result kvm_mips_emulate_tlbmiss_st(unsigned long cause, 1720enum emulation_result kvm_mips_emulate_tlbmiss_st(unsigned long cause,
@@ -1732,7 +1724,6 @@ enum emulation_result kvm_mips_emulate_tlbmiss_st(unsigned long cause,
1732{ 1724{
1733 struct mips_coproc *cop0 = vcpu->arch.cop0; 1725 struct mips_coproc *cop0 = vcpu->arch.cop0;
1734 struct kvm_vcpu_arch *arch = &vcpu->arch; 1726 struct kvm_vcpu_arch *arch = &vcpu->arch;
1735 enum emulation_result er = EMULATE_DONE;
1736 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | 1727 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) |
1737 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1728 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK);
1738 1729
@@ -1767,7 +1758,7 @@ enum emulation_result kvm_mips_emulate_tlbmiss_st(unsigned long cause,
1767 /* Blow away the shadow host TLBs */ 1758 /* Blow away the shadow host TLBs */
1768 kvm_mips_flush_host_tlb(1); 1759 kvm_mips_flush_host_tlb(1);
1769 1760
1770 return er; 1761 return EMULATE_DONE;
1771} 1762}
1772 1763
1773enum emulation_result kvm_mips_emulate_tlbinv_st(unsigned long cause, 1764enum emulation_result kvm_mips_emulate_tlbinv_st(unsigned long cause,
@@ -1777,7 +1768,6 @@ enum emulation_result kvm_mips_emulate_tlbinv_st(unsigned long cause,
1777{ 1768{
1778 struct mips_coproc *cop0 = vcpu->arch.cop0; 1769 struct mips_coproc *cop0 = vcpu->arch.cop0;
1779 struct kvm_vcpu_arch *arch = &vcpu->arch; 1770 struct kvm_vcpu_arch *arch = &vcpu->arch;
1780 enum emulation_result er = EMULATE_DONE;
1781 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | 1771 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) |
1782 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1772 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK);
1783 1773
@@ -1812,7 +1802,7 @@ enum emulation_result kvm_mips_emulate_tlbinv_st(unsigned long cause,
1812 /* Blow away the shadow host TLBs */ 1802 /* Blow away the shadow host TLBs */
1813 kvm_mips_flush_host_tlb(1); 1803 kvm_mips_flush_host_tlb(1);
1814 1804
1815 return er; 1805 return EMULATE_DONE;
1816} 1806}
1817 1807
1818/* TLBMOD: store into address matching TLB with Dirty bit off */ 1808/* TLBMOD: store into address matching TLB with Dirty bit off */
@@ -1853,7 +1843,6 @@ enum emulation_result kvm_mips_emulate_tlbmod(unsigned long cause,
1853 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | 1843 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) |
1854 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1844 (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK);
1855 struct kvm_vcpu_arch *arch = &vcpu->arch; 1845 struct kvm_vcpu_arch *arch = &vcpu->arch;
1856 enum emulation_result er = EMULATE_DONE;
1857 1846
1858 if ((kvm_read_c0_guest_status(cop0) & ST0_EXL) == 0) { 1847 if ((kvm_read_c0_guest_status(cop0) & ST0_EXL) == 0) {
1859 /* save old pc */ 1848 /* save old pc */
@@ -1884,7 +1873,7 @@ enum emulation_result kvm_mips_emulate_tlbmod(unsigned long cause,
1884 /* Blow away the shadow host TLBs */ 1873 /* Blow away the shadow host TLBs */
1885 kvm_mips_flush_host_tlb(1); 1874 kvm_mips_flush_host_tlb(1);
1886 1875
1887 return er; 1876 return EMULATE_DONE;
1888} 1877}
1889 1878
1890enum emulation_result kvm_mips_emulate_fpu_exc(unsigned long cause, 1879enum emulation_result kvm_mips_emulate_fpu_exc(unsigned long cause,
@@ -1894,7 +1883,6 @@ enum emulation_result kvm_mips_emulate_fpu_exc(unsigned long cause,
1894{ 1883{
1895 struct mips_coproc *cop0 = vcpu->arch.cop0; 1884 struct mips_coproc *cop0 = vcpu->arch.cop0;
1896 struct kvm_vcpu_arch *arch = &vcpu->arch; 1885 struct kvm_vcpu_arch *arch = &vcpu->arch;
1897 enum emulation_result er = EMULATE_DONE;
1898 1886
1899 if ((kvm_read_c0_guest_status(cop0) & ST0_EXL) == 0) { 1887 if ((kvm_read_c0_guest_status(cop0) & ST0_EXL) == 0) {
1900 /* save old pc */ 1888 /* save old pc */
@@ -1914,7 +1902,7 @@ enum emulation_result kvm_mips_emulate_fpu_exc(unsigned long cause,
1914 (T_COP_UNUSABLE << CAUSEB_EXCCODE)); 1902 (T_COP_UNUSABLE << CAUSEB_EXCCODE));
1915 kvm_change_c0_guest_cause(cop0, (CAUSEF_CE), (0x1 << CAUSEB_CE)); 1903 kvm_change_c0_guest_cause(cop0, (CAUSEF_CE), (0x1 << CAUSEB_CE));
1916 1904
1917 return er; 1905 return EMULATE_DONE;
1918} 1906}
1919 1907
1920enum emulation_result kvm_mips_emulate_ri_exc(unsigned long cause, 1908enum emulation_result kvm_mips_emulate_ri_exc(unsigned long cause,
diff --git a/arch/mips/kvm/kvm_mips_stats.c b/arch/mips/kvm/kvm_mips_stats.c
index 1ae9f88b4d38..a74d6024c5ad 100644
--- a/arch/mips/kvm/kvm_mips_stats.c
+++ b/arch/mips/kvm/kvm_mips_stats.c
@@ -63,7 +63,7 @@ char *kvm_cop0_str[N_MIPS_COPROC_REGS] = {
63 "DESAVE" 63 "DESAVE"
64}; 64};
65 65
66int kvm_mips_dump_stats(struct kvm_vcpu *vcpu) 66void kvm_mips_dump_stats(struct kvm_vcpu *vcpu)
67{ 67{
68#ifdef CONFIG_KVM_MIPS_DEBUG_COP0_COUNTERS 68#ifdef CONFIG_KVM_MIPS_DEBUG_COP0_COUNTERS
69 int i, j; 69 int i, j;
@@ -77,6 +77,4 @@ int kvm_mips_dump_stats(struct kvm_vcpu *vcpu)
77 } 77 }
78 } 78 }
79#endif 79#endif
80
81 return 0;
82} 80}