diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2011-11-14 05:19:00 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2011-11-14 05:19:08 -0500 |
commit | 09b538833b85521d937a06faf61e6a3273253cc0 (patch) | |
tree | f1d66c7dfd425b1efd3cce1ab8d9c38fe30beee1 /arch/s390/include/asm/pgtable.h | |
parent | 800252976be89611ef86d6d04442a821018ed949 (diff) |
[S390] fix pgste update logic
The pgste_update_all / pgste_update_young and pgste_set_pte need to
check if the pte entry contains a valid page address before the storage
key can be accessed. In addition pgste_set_pte needs to set the access
key and fetch protection bit of the new pte entry, not the old entry.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/include/asm/pgtable.h')
-rw-r--r-- | arch/s390/include/asm/pgtable.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 34ede0ea85a9..524d23b8610c 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h | |||
@@ -593,6 +593,8 @@ static inline pgste_t pgste_update_all(pte_t *ptep, pgste_t pgste) | |||
593 | unsigned long address, bits; | 593 | unsigned long address, bits; |
594 | unsigned char skey; | 594 | unsigned char skey; |
595 | 595 | ||
596 | if (!pte_present(*ptep)) | ||
597 | return pgste; | ||
596 | address = pte_val(*ptep) & PAGE_MASK; | 598 | address = pte_val(*ptep) & PAGE_MASK; |
597 | skey = page_get_storage_key(address); | 599 | skey = page_get_storage_key(address); |
598 | bits = skey & (_PAGE_CHANGED | _PAGE_REFERENCED); | 600 | bits = skey & (_PAGE_CHANGED | _PAGE_REFERENCED); |
@@ -625,6 +627,8 @@ static inline pgste_t pgste_update_young(pte_t *ptep, pgste_t pgste) | |||
625 | #ifdef CONFIG_PGSTE | 627 | #ifdef CONFIG_PGSTE |
626 | int young; | 628 | int young; |
627 | 629 | ||
630 | if (!pte_present(*ptep)) | ||
631 | return pgste; | ||
628 | young = page_reset_referenced(pte_val(*ptep) & PAGE_MASK); | 632 | young = page_reset_referenced(pte_val(*ptep) & PAGE_MASK); |
629 | /* Transfer page referenced bit to pte software bit (host view) */ | 633 | /* Transfer page referenced bit to pte software bit (host view) */ |
630 | if (young || (pgste_val(pgste) & RCP_HR_BIT)) | 634 | if (young || (pgste_val(pgste) & RCP_HR_BIT)) |
@@ -638,13 +642,15 @@ static inline pgste_t pgste_update_young(pte_t *ptep, pgste_t pgste) | |||
638 | 642 | ||
639 | } | 643 | } |
640 | 644 | ||
641 | static inline void pgste_set_pte(pte_t *ptep, pgste_t pgste) | 645 | static inline void pgste_set_pte(pte_t *ptep, pgste_t pgste, pte_t entry) |
642 | { | 646 | { |
643 | #ifdef CONFIG_PGSTE | 647 | #ifdef CONFIG_PGSTE |
644 | unsigned long address; | 648 | unsigned long address; |
645 | unsigned long okey, nkey; | 649 | unsigned long okey, nkey; |
646 | 650 | ||
647 | address = pte_val(*ptep) & PAGE_MASK; | 651 | if (!pte_present(entry)) |
652 | return; | ||
653 | address = pte_val(entry) & PAGE_MASK; | ||
648 | okey = nkey = page_get_storage_key(address); | 654 | okey = nkey = page_get_storage_key(address); |
649 | nkey &= ~(_PAGE_ACC_BITS | _PAGE_FP_BIT); | 655 | nkey &= ~(_PAGE_ACC_BITS | _PAGE_FP_BIT); |
650 | /* Set page access key and fetch protection bit from pgste */ | 656 | /* Set page access key and fetch protection bit from pgste */ |
@@ -712,7 +718,7 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, | |||
712 | 718 | ||
713 | if (mm_has_pgste(mm)) { | 719 | if (mm_has_pgste(mm)) { |
714 | pgste = pgste_get_lock(ptep); | 720 | pgste = pgste_get_lock(ptep); |
715 | pgste_set_pte(ptep, pgste); | 721 | pgste_set_pte(ptep, pgste, entry); |
716 | *ptep = entry; | 722 | *ptep = entry; |
717 | pgste_set_unlock(ptep, pgste); | 723 | pgste_set_unlock(ptep, pgste); |
718 | } else | 724 | } else |