Skip to content

Commit a0bf4f1

Browse files
Dominik Dingelborntraeger
authored andcommitted
KVM: s390/mm: new gmap_test_and_clear_dirty function
For live migration kvm needs to test and clear the dirty bit of guest pages. That for is ptep_test_and_clear_user_dirty, to be sure we are not racing with other code, we protect the pte. This needs to be done within the architecture memory management code. Signed-off-by: Dominik Dingel <[email protected]> Acked-by: Martin Schwidefsky <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
1 parent 0a61b22 commit a0bf4f1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

arch/s390/include/asm/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,8 @@ unsigned long __gmap_fault(unsigned long address, struct gmap *);
838838
unsigned long gmap_fault(unsigned long address, struct gmap *);
839839
void gmap_discard(unsigned long from, unsigned long to, struct gmap *);
840840
void __gmap_zap(unsigned long address, struct gmap *);
841+
bool gmap_test_and_clear_dirty(unsigned long address, struct gmap *);
842+
841843

842844
void gmap_register_ipte_notifier(struct gmap_notifier *);
843845
void gmap_unregister_ipte_notifier(struct gmap_notifier *);

arch/s390/mm/pgtable.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,27 @@ void s390_enable_skey(void)
14011401
}
14021402
EXPORT_SYMBOL_GPL(s390_enable_skey);
14031403

1404+
/*
1405+
* Test and reset if a guest page is dirty
1406+
*/
1407+
bool gmap_test_and_clear_dirty(unsigned long address, struct gmap *gmap)
1408+
{
1409+
pte_t *pte;
1410+
spinlock_t *ptl;
1411+
bool dirty = false;
1412+
1413+
pte = get_locked_pte(gmap->mm, address, &ptl);
1414+
if (unlikely(!pte))
1415+
return false;
1416+
1417+
if (ptep_test_and_clear_user_dirty(gmap->mm, address, pte))
1418+
dirty = true;
1419+
1420+
spin_unlock(ptl);
1421+
return dirty;
1422+
}
1423+
EXPORT_SYMBOL_GPL(gmap_test_and_clear_dirty);
1424+
14041425
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
14051426
int pmdp_clear_flush_young(struct vm_area_struct *vma, unsigned long address,
14061427
pmd_t *pmdp)

0 commit comments

Comments
 (0)