Right now, ZONE_DEVICE memory is always set PG_reserved. We want to
change that.

Rewrite hash_page_do_lazy_icache() to make sure the function produces the
same result once we stop setting ZONE_DEVICE pages PG_reserved.

Cc: Benjamin Herrenschmidt <b...@kernel.crashing.org>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Michael Ellerman <m...@ellerman.id.au>
Cc: "Aneesh Kumar K.V" <aneesh.ku...@linux.ibm.com>
Cc: Christophe Leroy <christophe.le...@c-s.fr>
Cc: Nicholas Piggin <npig...@gmail.com>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: Mike Rapoport <r...@linux.ibm.com>
Cc: YueHaibing <yuehaib...@huawei.com>
Signed-off-by: David Hildenbrand <da...@redhat.com>
---
 arch/powerpc/mm/book3s64/hash_utils.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/book3s64/hash_utils.c 
b/arch/powerpc/mm/book3s64/hash_utils.c
index 6c123760164e..a1566039e747 100644
--- a/arch/powerpc/mm/book3s64/hash_utils.c
+++ b/arch/powerpc/mm/book3s64/hash_utils.c
@@ -1084,13 +1084,15 @@ void hash__early_init_mmu_secondary(void)
  */
 unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap)
 {
-       struct page *page;
+       struct page *page = pfn_to_online_page(pte_pfn(pte));
 
-       if (!pfn_valid(pte_pfn(pte)))
+       /*
+        * We ignore any pages that are not online (not managed by the buddy).
+        * This includes ZONE_DEVICE pages.
+        */
+       if (!page)
                return pp;
 
-       page = pte_page(pte);
-
        /* page is dirty */
        if (!test_bit(PG_arch_1, &page->flags) && !PageReserved(page)) {
                if (trap == 0x400) {
-- 
2.21.0

Reply via email to