]> www.infradead.org Git - users/dwmw2/linux.git/commit
LoongArch: KVM: Clear LLBCTL if secondary mmu mapping is changed
authorBibo Mao <maobibo@loongson.cn>
Mon, 13 Jan 2025 13:37:17 +0000 (21:37 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 13 Jan 2025 13:37:17 +0000 (21:37 +0800)
commit4d38d0416ece7bab532e89a49f988a9954f12ee9
tree05995660f90db4db0ba3f900fb7d9bf8ea2423cb
parent5bc55a333a2f7316b58edc7573e8e893f7acb532
LoongArch: KVM: Clear LLBCTL if secondary mmu mapping is changed

LLBCTL is a separated guest CSR register from host, host exception ERET
instruction will clear the host LLBCTL CSR register, and guest exception
will clear the guest LLBCTL CSR register.

VCPU0 atomic64_fetch_add_unless     VCPU1 atomic64_fetch_add_unless
     ll.d    %[p],  %[c]
     beq     %[p],  %[u], 1f

Here secondary mmu mapping is changed, host hpa page is replaced with a
new page. And VCPU1 will execute atomic instruction on the new page.

                                       ll.d    %[p],  %[c]
                                       beq     %[p],  %[u], 1f
                                       add.d   %[rc], %[p], %[a]
                                       sc.d    %[rc], %[c]
     add.d   %[rc], %[p], %[a]
     sc.d    %[rc], %[c]

LLBCTL is set on VCPU0 and it represents the memory is not modified by
other VCPUs, sc.d will modify the memory directly.

So clear WCLLB of the guest LLBCTL register when mapping is the changed.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/main.c