Skip to content

Commit 32d4b99

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Add memory barrier before update pmd entry
When updating pmd entry such as allocating new pmd page or splitting huge page into normal page, it is necessary to firstly update all pte entries, and then update pmd entry. It is weak order with LoongArch system, there will be problem if other VCPUs see pmd update firstly while ptes are not updated. Here smp_wmb() is added to assure this. Signed-off-by: Bibo Mao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent b072cbf commit 32d4b99

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/loongarch/kvm/mmu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static kvm_pte_t *kvm_populate_gpa(struct kvm *kvm,
163163

164164
child = kvm_mmu_memory_cache_alloc(cache);
165165
_kvm_pte_init(child, ctx.invalid_ptes[ctx.level - 1]);
166+
smp_wmb(); /* Make pte visible before pmd */
166167
kvm_set_pte(entry, __pa(child));
167168
} else if (kvm_pte_huge(*entry)) {
168169
return entry;
@@ -746,6 +747,7 @@ static kvm_pte_t *kvm_split_huge(struct kvm_vcpu *vcpu, kvm_pte_t *ptep, gfn_t g
746747
val += PAGE_SIZE;
747748
}
748749

750+
smp_wmb(); /* Make pte visible before pmd */
749751
/* The later kvm_flush_tlb_gpa() will flush hugepage tlb */
750752
kvm_set_pte(ptep, __pa(child));
751753

0 commit comments

Comments
 (0)