forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/arch/mips/kvm/tlb.c
....@@ -20,8 +20,8 @@
2020
2121 #include <asm/cpu.h>
2222 #include <asm/bootinfo.h>
23
+#include <asm/mipsregs.h>
2324 #include <asm/mmu_context.h>
24
-#include <asm/pgtable.h>
2525 #include <asm/cacheflush.h>
2626 #include <asm/tlb.h>
2727 #include <asm/tlbdebug.h>
....@@ -469,7 +469,7 @@
469469 cvmmemctl2 |= CVMMEMCTL2_INHIBITTS;
470470 write_c0_cvmmemctl2(cvmmemctl2);
471471 break;
472
- };
472
+ }
473473
474474 /* Invalidate guest entries in guest TLB */
475475 write_gc0_entrylo0(0);
....@@ -486,7 +486,7 @@
486486 if (cvmmemctl2) {
487487 cvmmemctl2 &= ~CVMMEMCTL2_INHIBITTS;
488488 write_c0_cvmmemctl2(cvmmemctl2);
489
- };
489
+ }
490490
491491 write_gc0_index(old_index);
492492 write_gc0_entryhi(old_entryhi);
....@@ -622,6 +622,46 @@
622622 }
623623 EXPORT_SYMBOL_GPL(kvm_vz_load_guesttlb);
624624
625
+#ifdef CONFIG_CPU_LOONGSON64
626
+void kvm_loongson_clear_guest_vtlb(void)
627
+{
628
+ int idx = read_gc0_index();
629
+
630
+ /* Set root GuestID for root probe and write of guest TLB entry */
631
+ set_root_gid_to_guest_gid();
632
+
633
+ write_gc0_index(0);
634
+ guest_tlbinvf();
635
+ write_gc0_index(idx);
636
+
637
+ clear_root_gid();
638
+ set_c0_diag(LOONGSON_DIAG_ITLB | LOONGSON_DIAG_DTLB);
639
+}
640
+EXPORT_SYMBOL_GPL(kvm_loongson_clear_guest_vtlb);
641
+
642
+void kvm_loongson_clear_guest_ftlb(void)
643
+{
644
+ int i;
645
+ int idx = read_gc0_index();
646
+
647
+ /* Set root GuestID for root probe and write of guest TLB entry */
648
+ set_root_gid_to_guest_gid();
649
+
650
+ for (i = current_cpu_data.tlbsizevtlb;
651
+ i < (current_cpu_data.tlbsizevtlb +
652
+ current_cpu_data.tlbsizeftlbsets);
653
+ i++) {
654
+ write_gc0_index(i);
655
+ guest_tlbinvf();
656
+ }
657
+ write_gc0_index(idx);
658
+
659
+ clear_root_gid();
660
+ set_c0_diag(LOONGSON_DIAG_ITLB | LOONGSON_DIAG_DTLB);
661
+}
662
+EXPORT_SYMBOL_GPL(kvm_loongson_clear_guest_ftlb);
663
+#endif
664
+
625665 #endif
626666
627667 /**