diff options
| author | Dominik Dingel <dingel@linux.vnet.ibm.com> | 2014-03-24 09:27:58 -0400 |
|---|---|---|
| committer | Christian Borntraeger <borntraeger@de.ibm.com> | 2014-04-22 03:36:27 -0400 |
| commit | a0bf4f149bbfa2e31b5f4172c817afdb7b986733 (patch) | |
| tree | ed16368e498daaf4451241b5c734368a31986b1e | |
| parent | 0a61b222df75a6a69dc34816f7db2f61fee8c935 (diff) | |
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 <dingel@linux.vnet.ibm.com>
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
| -rw-r--r-- | arch/s390/include/asm/pgtable.h | 2 | ||||
| -rw-r--r-- | arch/s390/mm/pgtable.c | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index b2c630df0ca5..fcba5e03839f 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h | |||
| @@ -838,6 +838,8 @@ unsigned long __gmap_fault(unsigned long address, struct gmap *); | |||
| 838 | unsigned long gmap_fault(unsigned long address, struct gmap *); | 838 | unsigned long gmap_fault(unsigned long address, struct gmap *); |
| 839 | void gmap_discard(unsigned long from, unsigned long to, struct gmap *); | 839 | void gmap_discard(unsigned long from, unsigned long to, struct gmap *); |
| 840 | void __gmap_zap(unsigned long address, struct gmap *); | 840 | void __gmap_zap(unsigned long address, struct gmap *); |
| 841 | bool gmap_test_and_clear_dirty(unsigned long address, struct gmap *); | ||
| 842 | |||
| 841 | 843 | ||
| 842 | void gmap_register_ipte_notifier(struct gmap_notifier *); | 844 | void gmap_register_ipte_notifier(struct gmap_notifier *); |
| 843 | void gmap_unregister_ipte_notifier(struct gmap_notifier *); | 845 | void gmap_unregister_ipte_notifier(struct gmap_notifier *); |
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 1ddf975352a0..ea4a31b95990 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c | |||
| @@ -1401,6 +1401,27 @@ void s390_enable_skey(void) | |||
| 1401 | } | 1401 | } |
| 1402 | EXPORT_SYMBOL_GPL(s390_enable_skey); | 1402 | EXPORT_SYMBOL_GPL(s390_enable_skey); |
| 1403 | 1403 | ||
| 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 | |||
| 1404 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 1425 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
| 1405 | int pmdp_clear_flush_young(struct vm_area_struct *vma, unsigned long address, | 1426 | int pmdp_clear_flush_young(struct vm_area_struct *vma, unsigned long address, |
| 1406 | pmd_t *pmdp) | 1427 | pmd_t *pmdp) |
