88
88
89
89
#define KVM_HALT_POLL_NS_DEFAULT 500000
90
90
91
- #ifdef CONFIG_KVM_MIPS_VZ
92
91
extern unsigned long GUESTID_MASK ;
93
92
extern unsigned long GUESTID_FIRST_VERSION ;
94
93
extern unsigned long GUESTID_VERSION_MASK ;
95
- #endif
96
-
97
-
98
- /*
99
- * Special address that contains the comm page, used for reducing # of traps
100
- * This needs to be within 32Kb of 0x0 (so the zero register can be used), but
101
- * preferably not at 0x0 so that most kernel NULL pointer dereferences can be
102
- * caught.
103
- */
104
- #define KVM_GUEST_COMMPAGE_ADDR ((PAGE_SIZE > 0x8000) ? 0 : \
105
- (0x8000 - PAGE_SIZE))
106
94
107
- #define KVM_GUEST_KERNEL_MODE (vcpu ) ((kvm_read_c0_guest_status(vcpu->arch.cop0) & (ST0_EXL | ST0_ERL)) || \
108
- ((kvm_read_c0_guest_status(vcpu->arch.cop0) & KSU_USER) == 0))
109
-
110
- #define KVM_GUEST_KUSEG 0x00000000UL
111
- #define KVM_GUEST_KSEG0 0x40000000UL
112
- #define KVM_GUEST_KSEG1 0x40000000UL
113
- #define KVM_GUEST_KSEG23 0x60000000UL
114
- #define KVM_GUEST_KSEGX (a ) ((_ACAST32_(a)) & 0xe0000000)
115
- #define KVM_GUEST_CPHYSADDR (a ) ((_ACAST32_(a)) & 0x1fffffff)
116
-
117
- #define KVM_GUEST_CKSEG0ADDR (a ) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG0)
118
- #define KVM_GUEST_CKSEG1ADDR (a ) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG1)
119
- #define KVM_GUEST_CKSEG23ADDR (a ) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG23)
120
-
121
- /*
122
- * Map an address to a certain kernel segment
123
- */
124
- #define KVM_GUEST_KSEG0ADDR (a ) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG0)
125
- #define KVM_GUEST_KSEG1ADDR (a ) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG1)
126
- #define KVM_GUEST_KSEG23ADDR (a ) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG23)
127
-
128
- #define KVM_INVALID_PAGE 0xdeadbeef
129
95
#define KVM_INVALID_ADDR 0xdeadbeef
130
96
131
97
/*
@@ -165,7 +131,6 @@ struct kvm_vcpu_stat {
165
131
u64 fpe_exits ;
166
132
u64 msa_disabled_exits ;
167
133
u64 flush_dcache_exits ;
168
- #ifdef CONFIG_KVM_MIPS_VZ
169
134
u64 vz_gpsi_exits ;
170
135
u64 vz_gsfc_exits ;
171
136
u64 vz_hc_exits ;
@@ -176,7 +141,6 @@ struct kvm_vcpu_stat {
176
141
u64 vz_resvd_exits ;
177
142
#ifdef CONFIG_CPU_LOONGSON64
178
143
u64 vz_cpucfg_exits ;
179
- #endif
180
144
#endif
181
145
u64 halt_successful_poll ;
182
146
u64 halt_attempted_poll ;
@@ -303,14 +267,6 @@ enum emulation_result {
303
267
EMULATE_HYPERCALL , /* HYPCALL instruction */
304
268
};
305
269
306
- #define mips3_paddr_to_tlbpfn (x ) \
307
- (((unsigned long)(x) >> MIPS3_PG_SHIFT) & MIPS3_PG_FRAME)
308
- #define mips3_tlbpfn_to_paddr (x ) \
309
- ((unsigned long)((x) & MIPS3_PG_FRAME) << MIPS3_PG_SHIFT)
310
-
311
- #define MIPS3_PG_SHIFT 6
312
- #define MIPS3_PG_FRAME 0x3fffffc0
313
-
314
270
#if defined(CONFIG_64BIT )
315
271
#define VPN2_MASK GENMASK(cpu_vmbits - 1, 13)
316
272
#else
@@ -337,7 +293,6 @@ struct kvm_mips_tlb {
337
293
#define KVM_MIPS_AUX_FPU 0x1
338
294
#define KVM_MIPS_AUX_MSA 0x2
339
295
340
- #define KVM_MIPS_GUEST_TLB_SIZE 64
341
296
struct kvm_vcpu_arch {
342
297
void * guest_ebase ;
343
298
int (* vcpu_run )(struct kvm_vcpu * vcpu );
@@ -370,9 +325,6 @@ struct kvm_vcpu_arch {
370
325
/* COP0 State */
371
326
struct mips_coproc * cop0 ;
372
327
373
- /* Host KSEG0 address of the EI/DI offset */
374
- void * kseg0_commpage ;
375
-
376
328
/* Resume PC after MMIO completion */
377
329
unsigned long io_pc ;
378
330
/* GPR used as IO source/target */
@@ -398,19 +350,9 @@ struct kvm_vcpu_arch {
398
350
/* Bitmask of pending exceptions to be cleared */
399
351
unsigned long pending_exceptions_clr ;
400
352
401
- /* S/W Based TLB for guest */
402
- struct kvm_mips_tlb guest_tlb [KVM_MIPS_GUEST_TLB_SIZE ];
403
-
404
- /* Guest kernel/user [partial] mm */
405
- struct mm_struct guest_kernel_mm , guest_user_mm ;
406
-
407
- /* Guest ASID of last user mode execution */
408
- unsigned int last_user_gasid ;
409
-
410
353
/* Cache some mmu pages needed inside spinlock regions */
411
354
struct kvm_mmu_memory_cache mmu_page_cache ;
412
355
413
- #ifdef CONFIG_KVM_MIPS_VZ
414
356
/* vcpu's vzguestid is different on each host cpu in an smp system */
415
357
u32 vzguestid [NR_CPUS ];
416
358
@@ -421,7 +363,6 @@ struct kvm_vcpu_arch {
421
363
422
364
/* emulated guest MAAR registers */
423
365
unsigned long maar [6 ];
424
- #endif
425
366
426
367
/* Last CPU the VCPU state was loaded on */
427
368
int last_sched_cpu ;
@@ -651,20 +592,6 @@ static inline void kvm_change_##name1(struct mips_coproc *cop0, \
651
592
__BUILD_KVM_ATOMIC_SAVED(name, type, _reg, sel) \
652
593
__BUILD_KVM_SET_WRAP(c0_guest_##name, sw_gc0_##name, type)
653
594
654
- #ifndef CONFIG_KVM_MIPS_VZ
655
-
656
- /*
657
- * T&E (trap & emulate software based virtualisation)
658
- * We generate the common accessors operating exclusively on the saved context
659
- * in RAM.
660
- */
661
-
662
- #define __BUILD_KVM_RW_HW __BUILD_KVM_RW_SW
663
- #define __BUILD_KVM_SET_HW __BUILD_KVM_SET_SW
664
- #define __BUILD_KVM_ATOMIC_HW __BUILD_KVM_ATOMIC_SW
665
-
666
- #else
667
-
668
595
/*
669
596
* VZ (hardware assisted virtualisation)
670
597
* These macros use the active guest state in VZ mode (hardware registers),
@@ -697,8 +624,6 @@ static inline void kvm_change_##name1(struct mips_coproc *cop0, \
697
624
*/
698
625
#define __BUILD_KVM_ATOMIC_HW __BUILD_KVM_SET_HW
699
626
700
- #endif
701
-
702
627
/*
703
628
* Define accessors for CP0 registers that are accessible to the guest. These
704
629
* are primarily used by common emulation code, which may need to access the
@@ -874,42 +799,9 @@ void kvm_drop_fpu(struct kvm_vcpu *vcpu);
874
799
void kvm_lose_fpu (struct kvm_vcpu * vcpu );
875
800
876
801
/* TLB handling */
877
- u32 kvm_get_kernel_asid (struct kvm_vcpu * vcpu );
878
-
879
- u32 kvm_get_user_asid (struct kvm_vcpu * vcpu );
880
-
881
- u32 kvm_get_commpage_asid (struct kvm_vcpu * vcpu );
882
-
883
- #ifdef CONFIG_KVM_MIPS_VZ
884
802
int kvm_mips_handle_vz_root_tlb_fault (unsigned long badvaddr ,
885
803
struct kvm_vcpu * vcpu , bool write_fault );
886
- #endif
887
- extern int kvm_mips_handle_kseg0_tlb_fault (unsigned long badbaddr ,
888
- struct kvm_vcpu * vcpu ,
889
- bool write_fault );
890
-
891
- extern int kvm_mips_handle_commpage_tlb_fault (unsigned long badvaddr ,
892
- struct kvm_vcpu * vcpu );
893
804
894
- extern int kvm_mips_handle_mapped_seg_tlb_fault (struct kvm_vcpu * vcpu ,
895
- struct kvm_mips_tlb * tlb ,
896
- unsigned long gva ,
897
- bool write_fault );
898
-
899
- extern enum emulation_result kvm_mips_handle_tlbmiss (u32 cause ,
900
- u32 * opc ,
901
- struct kvm_vcpu * vcpu ,
902
- bool write_fault );
903
-
904
- extern void kvm_mips_dump_host_tlbs (void );
905
- extern void kvm_mips_dump_guest_tlbs (struct kvm_vcpu * vcpu );
906
- extern int kvm_mips_host_tlb_inv (struct kvm_vcpu * vcpu , unsigned long entryhi ,
907
- bool user , bool kernel );
908
-
909
- extern int kvm_mips_guest_tlb_lookup (struct kvm_vcpu * vcpu ,
910
- unsigned long entryhi );
911
-
912
- #ifdef CONFIG_KVM_MIPS_VZ
913
805
int kvm_vz_host_tlb_inv (struct kvm_vcpu * vcpu , unsigned long entryhi );
914
806
int kvm_vz_guest_tlb_lookup (struct kvm_vcpu * vcpu , unsigned long gva ,
915
807
unsigned long * gpa );
@@ -923,48 +815,13 @@ void kvm_vz_load_guesttlb(const struct kvm_mips_tlb *buf, unsigned int index,
923
815
void kvm_loongson_clear_guest_vtlb (void );
924
816
void kvm_loongson_clear_guest_ftlb (void );
925
817
#endif
926
- #endif
927
-
928
- void kvm_mips_suspend_mm (int cpu );
929
- void kvm_mips_resume_mm (int cpu );
930
818
931
819
/* MMU handling */
932
820
933
- /**
934
- * enum kvm_mips_flush - Types of MMU flushes.
935
- * @KMF_USER: Flush guest user virtual memory mappings.
936
- * Guest USeg only.
937
- * @KMF_KERN: Flush guest kernel virtual memory mappings.
938
- * Guest USeg and KSeg2/3.
939
- * @KMF_GPA: Flush guest physical memory mappings.
940
- * Also includes KSeg0 if KMF_KERN is set.
941
- */
942
- enum kvm_mips_flush {
943
- KMF_USER = 0x0 ,
944
- KMF_KERN = 0x1 ,
945
- KMF_GPA = 0x2 ,
946
- };
947
- void kvm_mips_flush_gva_pt (pgd_t * pgd , enum kvm_mips_flush flags );
948
821
bool kvm_mips_flush_gpa_pt (struct kvm * kvm , gfn_t start_gfn , gfn_t end_gfn );
949
822
int kvm_mips_mkclean_gpa_pt (struct kvm * kvm , gfn_t start_gfn , gfn_t end_gfn );
950
823
pgd_t * kvm_pgd_alloc (void );
951
824
void kvm_mmu_free_memory_caches (struct kvm_vcpu * vcpu );
952
- void kvm_trap_emul_invalidate_gva (struct kvm_vcpu * vcpu , unsigned long addr ,
953
- bool user );
954
- void kvm_trap_emul_gva_lockless_begin (struct kvm_vcpu * vcpu );
955
- void kvm_trap_emul_gva_lockless_end (struct kvm_vcpu * vcpu );
956
-
957
- enum kvm_mips_fault_result {
958
- KVM_MIPS_MAPPED = 0 ,
959
- KVM_MIPS_GVA ,
960
- KVM_MIPS_GPA ,
961
- KVM_MIPS_TLB ,
962
- KVM_MIPS_TLBINV ,
963
- KVM_MIPS_TLBMOD ,
964
- };
965
- enum kvm_mips_fault_result kvm_trap_emul_gva_fault (struct kvm_vcpu * vcpu ,
966
- unsigned long gva ,
967
- bool write );
968
825
969
826
#define KVM_ARCH_WANT_MMU_NOTIFIER
970
827
int kvm_unmap_hva_range (struct kvm * kvm ,
@@ -974,7 +831,6 @@ int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
974
831
int kvm_test_age_hva (struct kvm * kvm , unsigned long hva );
975
832
976
833
/* Emulation */
977
- int kvm_get_inst (u32 * opc , struct kvm_vcpu * vcpu , u32 * out );
978
834
enum emulation_result update_pc (struct kvm_vcpu * vcpu , u32 cause );
979
835
int kvm_get_badinstr (u32 * opc , struct kvm_vcpu * vcpu , u32 * out );
980
836
int kvm_get_badinstrp (u32 * opc , struct kvm_vcpu * vcpu , u32 * out );
@@ -1006,68 +862,6 @@ static inline bool kvm_is_ifetch_fault(struct kvm_vcpu_arch *vcpu)
1006
862
return false;
1007
863
}
1008
864
1009
- extern enum emulation_result kvm_mips_emulate_inst (u32 cause ,
1010
- u32 * opc ,
1011
- struct kvm_vcpu * vcpu );
1012
-
1013
- long kvm_mips_guest_exception_base (struct kvm_vcpu * vcpu );
1014
-
1015
- extern enum emulation_result kvm_mips_emulate_syscall (u32 cause ,
1016
- u32 * opc ,
1017
- struct kvm_vcpu * vcpu );
1018
-
1019
- extern enum emulation_result kvm_mips_emulate_tlbmiss_ld (u32 cause ,
1020
- u32 * opc ,
1021
- struct kvm_vcpu * vcpu );
1022
-
1023
- extern enum emulation_result kvm_mips_emulate_tlbinv_ld (u32 cause ,
1024
- u32 * opc ,
1025
- struct kvm_vcpu * vcpu );
1026
-
1027
- extern enum emulation_result kvm_mips_emulate_tlbmiss_st (u32 cause ,
1028
- u32 * opc ,
1029
- struct kvm_vcpu * vcpu );
1030
-
1031
- extern enum emulation_result kvm_mips_emulate_tlbinv_st (u32 cause ,
1032
- u32 * opc ,
1033
- struct kvm_vcpu * vcpu );
1034
-
1035
- extern enum emulation_result kvm_mips_emulate_tlbmod (u32 cause ,
1036
- u32 * opc ,
1037
- struct kvm_vcpu * vcpu );
1038
-
1039
- extern enum emulation_result kvm_mips_emulate_fpu_exc (u32 cause ,
1040
- u32 * opc ,
1041
- struct kvm_vcpu * vcpu );
1042
-
1043
- extern enum emulation_result kvm_mips_handle_ri (u32 cause ,
1044
- u32 * opc ,
1045
- struct kvm_vcpu * vcpu );
1046
-
1047
- extern enum emulation_result kvm_mips_emulate_ri_exc (u32 cause ,
1048
- u32 * opc ,
1049
- struct kvm_vcpu * vcpu );
1050
-
1051
- extern enum emulation_result kvm_mips_emulate_bp_exc (u32 cause ,
1052
- u32 * opc ,
1053
- struct kvm_vcpu * vcpu );
1054
-
1055
- extern enum emulation_result kvm_mips_emulate_trap_exc (u32 cause ,
1056
- u32 * opc ,
1057
- struct kvm_vcpu * vcpu );
1058
-
1059
- extern enum emulation_result kvm_mips_emulate_msafpe_exc (u32 cause ,
1060
- u32 * opc ,
1061
- struct kvm_vcpu * vcpu );
1062
-
1063
- extern enum emulation_result kvm_mips_emulate_fpe_exc (u32 cause ,
1064
- u32 * opc ,
1065
- struct kvm_vcpu * vcpu );
1066
-
1067
- extern enum emulation_result kvm_mips_emulate_msadis_exc (u32 cause ,
1068
- u32 * opc ,
1069
- struct kvm_vcpu * vcpu );
1070
-
1071
865
extern enum emulation_result kvm_mips_complete_mmio_load (struct kvm_vcpu * vcpu );
1072
866
1073
867
u32 kvm_mips_read_count (struct kvm_vcpu * vcpu );
@@ -1087,26 +881,9 @@ ktime_t kvm_mips_freeze_hrtimer(struct kvm_vcpu *vcpu, u32 *count);
1087
881
int kvm_mips_restore_hrtimer (struct kvm_vcpu * vcpu , ktime_t before ,
1088
882
u32 count , int min_drift );
1089
883
1090
- #ifdef CONFIG_KVM_MIPS_VZ
1091
884
void kvm_vz_acquire_htimer (struct kvm_vcpu * vcpu );
1092
885
void kvm_vz_lose_htimer (struct kvm_vcpu * vcpu );
1093
- #else
1094
- static inline void kvm_vz_acquire_htimer (struct kvm_vcpu * vcpu ) {}
1095
- static inline void kvm_vz_lose_htimer (struct kvm_vcpu * vcpu ) {}
1096
- #endif
1097
-
1098
- enum emulation_result kvm_mips_check_privilege (u32 cause ,
1099
- u32 * opc ,
1100
- struct kvm_vcpu * vcpu );
1101
886
1102
- enum emulation_result kvm_mips_emulate_cache (union mips_instruction inst ,
1103
- u32 * opc ,
1104
- u32 cause ,
1105
- struct kvm_vcpu * vcpu );
1106
- enum emulation_result kvm_mips_emulate_CP0 (union mips_instruction inst ,
1107
- u32 * opc ,
1108
- u32 cause ,
1109
- struct kvm_vcpu * vcpu );
1110
887
enum emulation_result kvm_mips_emulate_store (union mips_instruction inst ,
1111
888
u32 cause ,
1112
889
struct kvm_vcpu * vcpu );
@@ -1117,27 +894,12 @@ enum emulation_result kvm_mips_emulate_load(union mips_instruction inst,
1117
894
/* COP0 */
1118
895
enum emulation_result kvm_mips_emul_wait (struct kvm_vcpu * vcpu );
1119
896
1120
- unsigned int kvm_mips_config1_wrmask (struct kvm_vcpu * vcpu );
1121
- unsigned int kvm_mips_config3_wrmask (struct kvm_vcpu * vcpu );
1122
- unsigned int kvm_mips_config4_wrmask (struct kvm_vcpu * vcpu );
1123
- unsigned int kvm_mips_config5_wrmask (struct kvm_vcpu * vcpu );
1124
-
1125
897
/* Hypercalls (hypcall.c) */
1126
898
1127
899
enum emulation_result kvm_mips_emul_hypcall (struct kvm_vcpu * vcpu ,
1128
900
union mips_instruction inst );
1129
901
int kvm_mips_handle_hypcall (struct kvm_vcpu * vcpu );
1130
902
1131
- /* Dynamic binary translation */
1132
- extern int kvm_mips_trans_cache_index (union mips_instruction inst ,
1133
- u32 * opc , struct kvm_vcpu * vcpu );
1134
- extern int kvm_mips_trans_cache_va (union mips_instruction inst , u32 * opc ,
1135
- struct kvm_vcpu * vcpu );
1136
- extern int kvm_mips_trans_mfc0 (union mips_instruction inst , u32 * opc ,
1137
- struct kvm_vcpu * vcpu );
1138
- extern int kvm_mips_trans_mtc0 (union mips_instruction inst , u32 * opc ,
1139
- struct kvm_vcpu * vcpu );
1140
-
1141
903
/* Misc */
1142
904
extern void kvm_mips_dump_stats (struct kvm_vcpu * vcpu );
1143
905
extern unsigned long kvm_mips_get_ramsize (struct kvm * kvm );
0 commit comments