Skip to content

Commit 78d68a2

Browse files
gaosong-loongsonKexyBiscuit
authored andcommitted
DEEPIN: LoongArch: fix migrate issue
Upstream: no when read_fault, we shoul't set the page _PAGE_WRITE. this may case nest write fault issue. Signed-off-by: Song Gao <[email protected]> Change-Id: I443ac32d152c43635c0bafbe3da9b9479f4e546d Signed-off-by: Xianglai Li <[email protected]> Link: deepin-community/kernel@41f07a155ee6 Link: https://git.kernel.org/torvalds/c/f3b65bbaed7c # conflict Signed-off-by: Xi Ruoyao <[email protected]>
1 parent a4782b4 commit 78d68a2

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

arch/loongarch/include/asm/kvm_mmu.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ static inline void kvm_set_pte(kvm_pte_t *ptep, kvm_pte_t val)
6161
WRITE_ONCE(*ptep, val);
6262
}
6363

64-
static inline int kvm_pte_write(kvm_pte_t pte) { return pte & _PAGE_WRITE; }
65-
static inline int kvm_record_pte_write_able(kvm_pte_t pte) { return pte & KVM_RECORD_PAGE_WRITE_ABLE; }
64+
static inline int kvm_pte_write(kvm_pte_t pte) { return pte & KVM_RECORD_PAGE_WRITE_ABLE; }
6665
static inline int kvm_pte_dirty(kvm_pte_t pte) { return pte & _PAGE_DIRTY; }
6766
static inline int kvm_pte_young(kvm_pte_t pte) { return pte & _PAGE_ACCESSED; }
6867
static inline int kvm_pte_huge(kvm_pte_t pte) { return pte & _PAGE_HUGE; }
@@ -79,7 +78,12 @@ static inline kvm_pte_t kvm_pte_mkold(kvm_pte_t pte)
7978

8079
static inline kvm_pte_t kvm_pte_mkdirty(kvm_pte_t pte)
8180
{
82-
return pte | _PAGE_DIRTY;
81+
return pte | _PAGE_DIRTY | _PAGE_WRITE;
82+
}
83+
84+
static inline kvm_pte_t kvm_pte_mkwrite(kvm_pte_t pte)
85+
{
86+
return pte | KVM_RECORD_PAGE_WRITE_ABLE;
8387
}
8488

8589
static inline kvm_pte_t kvm_pte_mkclean(kvm_pte_t pte)

arch/loongarch/kvm/mmu.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,6 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
568568

569569
/* Track access to pages marked old */
570570
new = kvm_pte_mkyoung(*ptep);
571-
572-
/* We restore the write property of
573-
* the page table entry according to
574-
* KVM_RECORD_PAGE_WRITE_ABLE
575-
*/
576-
if (kvm_record_pte_write_able(new))
577-
new |= _PAGE_WRITE;
578-
579571
if (write && !kvm_pte_dirty(new)) {
580572
if (!kvm_pte_write(new)) {
581573
ret = -EFAULT;
@@ -869,9 +861,9 @@ static int kvm_map_page(struct kvm_vcpu *vcpu, unsigned long gpa, bool write)
869861
* to record it to restore the write attribute of the page entry,
870862
* in the fast path kvm_map_page_fast for page table processing
871863
*/
872-
prot_bits |= _PAGE_WRITE | KVM_RECORD_PAGE_WRITE_ABLE;
864+
prot_bits = kvm_pte_mkwrite(prot_bits);
873865
if (write)
874-
prot_bits |= __WRITEABLE;
866+
prot_bits = kvm_pte_mkdirty(prot_bits);
875867
}
876868

877869
/* Disable dirty logging on HugePages */

0 commit comments

Comments
 (0)