All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: catalin.marinas@arm.com, will.deacon@arm.com,
	mark.rutland@arm.com, yuzhao@google.com
Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH] KVM: ARM: Remove pgtable page standard functions from stage-2 page tables
Date: Tue, 12 Mar 2019 07:49:02 +0530	[thread overview]
Message-ID: <1552357142-636-1-git-send-email-anshuman.khandual@arm.com> (raw)
In-Reply-To: <20190312005749.30166-3-yuzhao@google.com>

ARM64 standard pgtable functions are going to use pgtable_page_[ctor|dtor]
or pgtable_pmd_page_[ctor|dtor] constructs. At present KVM guest stage-2
PUD|PMD|PTE level page tabe pages are allocated with __get_free_page()
via mmu_memory_cache_alloc() but released with standard pud|pmd_free() or
pte_free_kernel(). These will fail once they start calling into pgtable_
[pmd]_page_dtor() for pages which never originally went through respective
constructor functions. Hence convert all stage-2 page table page release
functions to call buddy directly while freeing pages.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/arm/include/asm/stage2_pgtable.h   | 4 ++--
 arch/arm64/include/asm/stage2_pgtable.h | 4 ++--
 virt/kvm/arm/mmu.c                      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/stage2_pgtable.h b/arch/arm/include/asm/stage2_pgtable.h
index de2089501b8b..417a3be00718 100644
--- a/arch/arm/include/asm/stage2_pgtable.h
+++ b/arch/arm/include/asm/stage2_pgtable.h
@@ -32,14 +32,14 @@
 #define stage2_pgd_present(kvm, pgd)		pgd_present(pgd)
 #define stage2_pgd_populate(kvm, pgd, pud)	pgd_populate(NULL, pgd, pud)
 #define stage2_pud_offset(kvm, pgd, address)	pud_offset(pgd, address)
-#define stage2_pud_free(kvm, pud)		pud_free(NULL, pud)
+#define stage2_pud_free(kvm, pud)		free_page((unsigned long)pud)
 
 #define stage2_pud_none(kvm, pud)		pud_none(pud)
 #define stage2_pud_clear(kvm, pud)		pud_clear(pud)
 #define stage2_pud_present(kvm, pud)		pud_present(pud)
 #define stage2_pud_populate(kvm, pud, pmd)	pud_populate(NULL, pud, pmd)
 #define stage2_pmd_offset(kvm, pud, address)	pmd_offset(pud, address)
-#define stage2_pmd_free(kvm, pmd)		pmd_free(NULL, pmd)
+#define stage2_pmd_free(kvm, pmd)		free_page((unsigned long)pmd)
 
 #define stage2_pud_huge(kvm, pud)		pud_huge(pud)
 
diff --git a/arch/arm64/include/asm/stage2_pgtable.h b/arch/arm64/include/asm/stage2_pgtable.h
index 5412fa40825e..915809e4ac32 100644
--- a/arch/arm64/include/asm/stage2_pgtable.h
+++ b/arch/arm64/include/asm/stage2_pgtable.h
@@ -119,7 +119,7 @@ static inline pud_t *stage2_pud_offset(struct kvm *kvm,
 static inline void stage2_pud_free(struct kvm *kvm, pud_t *pud)
 {
 	if (kvm_stage2_has_pud(kvm))
-		pud_free(NULL, pud);
+		free_page((unsigned long)pud);
 }
 
 static inline bool stage2_pud_table_empty(struct kvm *kvm, pud_t *pudp)
@@ -192,7 +192,7 @@ static inline pmd_t *stage2_pmd_offset(struct kvm *kvm,
 static inline void stage2_pmd_free(struct kvm *kvm, pmd_t *pmd)
 {
 	if (kvm_stage2_has_pmd(kvm))
-		pmd_free(NULL, pmd);
+		free_page((unsigned long)pmd);
 }
 
 static inline bool stage2_pud_huge(struct kvm *kvm, pud_t pud)
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index e9d28a7ca673..00bd79a2f0b1 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -191,7 +191,7 @@ static void clear_stage2_pmd_entry(struct kvm *kvm, pmd_t *pmd, phys_addr_t addr
 	VM_BUG_ON(pmd_thp_or_huge(*pmd));
 	pmd_clear(pmd);
 	kvm_tlb_flush_vmid_ipa(kvm, addr);
-	pte_free_kernel(NULL, pte_table);
+	__free_page(virt_to_page(pte_table));
 	put_page(virt_to_page(pmd));
 }
 
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: catalin.marinas@arm.com, will.deacon@arm.com,
	mark.rutland@arm.com, yuzhao@google.com
Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH] KVM: ARM: Remove pgtable page standard functions from stage-2 page tables
Date: Tue, 12 Mar 2019 07:49:02 +0530	[thread overview]
Message-ID: <1552357142-636-1-git-send-email-anshuman.khandual@arm.com> (raw)
In-Reply-To: <20190312005749.30166-3-yuzhao@google.com>

ARM64 standard pgtable functions are going to use pgtable_page_[ctor|dtor]
or pgtable_pmd_page_[ctor|dtor] constructs. At present KVM guest stage-2
PUD|PMD|PTE level page tabe pages are allocated with __get_free_page()
via mmu_memory_cache_alloc() but released with standard pud|pmd_free() or
pte_free_kernel(). These will fail once they start calling into pgtable_
[pmd]_page_dtor() for pages which never originally went through respective
constructor functions. Hence convert all stage-2 page table page release
functions to call buddy directly while freeing pages.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/arm/include/asm/stage2_pgtable.h   | 4 ++--
 arch/arm64/include/asm/stage2_pgtable.h | 4 ++--
 virt/kvm/arm/mmu.c                      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/stage2_pgtable.h b/arch/arm/include/asm/stage2_pgtable.h
index de2089501b8b..417a3be00718 100644
--- a/arch/arm/include/asm/stage2_pgtable.h
+++ b/arch/arm/include/asm/stage2_pgtable.h
@@ -32,14 +32,14 @@
 #define stage2_pgd_present(kvm, pgd)		pgd_present(pgd)
 #define stage2_pgd_populate(kvm, pgd, pud)	pgd_populate(NULL, pgd, pud)
 #define stage2_pud_offset(kvm, pgd, address)	pud_offset(pgd, address)
-#define stage2_pud_free(kvm, pud)		pud_free(NULL, pud)
+#define stage2_pud_free(kvm, pud)		free_page((unsigned long)pud)
 
 #define stage2_pud_none(kvm, pud)		pud_none(pud)
 #define stage2_pud_clear(kvm, pud)		pud_clear(pud)
 #define stage2_pud_present(kvm, pud)		pud_present(pud)
 #define stage2_pud_populate(kvm, pud, pmd)	pud_populate(NULL, pud, pmd)
 #define stage2_pmd_offset(kvm, pud, address)	pmd_offset(pud, address)
-#define stage2_pmd_free(kvm, pmd)		pmd_free(NULL, pmd)
+#define stage2_pmd_free(kvm, pmd)		free_page((unsigned long)pmd)
 
 #define stage2_pud_huge(kvm, pud)		pud_huge(pud)
 
diff --git a/arch/arm64/include/asm/stage2_pgtable.h b/arch/arm64/include/asm/stage2_pgtable.h
index 5412fa40825e..915809e4ac32 100644
--- a/arch/arm64/include/asm/stage2_pgtable.h
+++ b/arch/arm64/include/asm/stage2_pgtable.h
@@ -119,7 +119,7 @@ static inline pud_t *stage2_pud_offset(struct kvm *kvm,
 static inline void stage2_pud_free(struct kvm *kvm, pud_t *pud)
 {
 	if (kvm_stage2_has_pud(kvm))
-		pud_free(NULL, pud);
+		free_page((unsigned long)pud);
 }
 
 static inline bool stage2_pud_table_empty(struct kvm *kvm, pud_t *pudp)
@@ -192,7 +192,7 @@ static inline pmd_t *stage2_pmd_offset(struct kvm *kvm,
 static inline void stage2_pmd_free(struct kvm *kvm, pmd_t *pmd)
 {
 	if (kvm_stage2_has_pmd(kvm))
-		pmd_free(NULL, pmd);
+		free_page((unsigned long)pmd);
 }
 
 static inline bool stage2_pud_huge(struct kvm *kvm, pud_t pud)
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index e9d28a7ca673..00bd79a2f0b1 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -191,7 +191,7 @@ static void clear_stage2_pmd_entry(struct kvm *kvm, pmd_t *pmd, phys_addr_t addr
 	VM_BUG_ON(pmd_thp_or_huge(*pmd));
 	pmd_clear(pmd);
 	kvm_tlb_flush_vmid_ipa(kvm, addr);
-	pte_free_kernel(NULL, pte_table);
+	__free_page(virt_to_page(pte_table));
 	put_page(virt_to_page(pmd));
 }
 
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-03-12  2:19 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 21:16 [PATCH] arm64: mm: enable per pmd page table lock Yu Zhao
2019-02-14 21:16 ` Yu Zhao
2019-02-18 15:12 ` Will Deacon
2019-02-18 15:12   ` Will Deacon
2019-02-18 19:49   ` Yu Zhao
2019-02-18 19:49     ` Yu Zhao
2019-02-18 20:48     ` Yu Zhao
2019-02-18 20:48       ` Yu Zhao
2019-02-19  4:09     ` Anshuman Khandual
2019-02-19  4:09       ` Anshuman Khandual
2019-02-18 23:13 ` [PATCH v2 1/3] arm64: mm: use appropriate ctors for page tables Yu Zhao
2019-02-18 23:13   ` Yu Zhao
2019-02-18 23:13   ` [PATCH v2 2/3] arm64: mm: don't call page table ctors for init_mm Yu Zhao
2019-02-18 23:13     ` Yu Zhao
2019-02-26 15:13     ` Mark Rutland
2019-02-26 15:13       ` Mark Rutland
2019-03-09  3:52       ` Yu Zhao
2019-03-09  3:52         ` Yu Zhao
2019-02-18 23:13   ` [PATCH v2 3/3] arm64: mm: enable per pmd page table lock Yu Zhao
2019-02-18 23:13     ` Yu Zhao
2019-02-19  4:21   ` [PATCH v2 1/3] arm64: mm: use appropriate ctors for page tables Anshuman Khandual
2019-02-19  4:21     ` Anshuman Khandual
2019-02-19  5:32     ` Yu Zhao
2019-02-19  5:32       ` Yu Zhao
2019-02-19  6:17       ` Anshuman Khandual
2019-02-19  6:17         ` Anshuman Khandual
2019-02-19 22:28         ` Yu Zhao
2019-02-19 22:28           ` Yu Zhao
2019-02-20 10:27           ` Anshuman Khandual
2019-02-20 10:27             ` Anshuman Khandual
2019-02-20 12:24             ` Matthew Wilcox
2019-02-20 12:24               ` Matthew Wilcox
2019-02-20 20:22             ` Yu Zhao
2019-02-20 20:22               ` Yu Zhao
2019-02-20 20:59               ` Matthew Wilcox
2019-02-20 20:59                 ` Matthew Wilcox
2019-02-20 20:59                 ` Matthew Wilcox
2019-02-20  1:34         ` Matthew Wilcox
2019-02-20  1:34           ` Matthew Wilcox
2019-02-20  1:34           ` Matthew Wilcox
2019-02-20  3:20           ` Anshuman Khandual
2019-02-20  3:20             ` Anshuman Khandual
2019-02-20 21:03       ` Matthew Wilcox
2019-02-20 21:03         ` Matthew Wilcox
2019-02-20 21:03         ` Matthew Wilcox
2019-02-26 15:12   ` Mark Rutland
2019-02-26 15:12     ` Mark Rutland
2019-03-09  4:01     ` Yu Zhao
2019-03-09  4:01       ` Yu Zhao
2019-03-09  4:01       ` Yu Zhao
2019-03-10  1:19   ` [PATCH v3 " Yu Zhao
2019-03-10  1:19     ` Yu Zhao
2019-03-10  1:19     ` Yu Zhao
2019-03-10  1:19     ` [PATCH v3 2/3] arm64: mm: don't call page table ctors for init_mm Yu Zhao
2019-03-10  1:19       ` Yu Zhao
2019-03-10  1:19       ` Yu Zhao
2019-03-10  1:19     ` [PATCH v3 3/3] arm64: mm: enable per pmd page table lock Yu Zhao
2019-03-10  1:19       ` Yu Zhao
2019-03-10  1:19       ` Yu Zhao
2019-03-11  8:28       ` Anshuman Khandual
2019-03-11  8:28         ` Anshuman Khandual
2019-03-11 23:10         ` Yu Zhao
2019-03-11 23:10           ` Yu Zhao
2019-03-11 12:12       ` Mark Rutland
2019-03-11 12:12         ` Mark Rutland
2019-03-11 12:57         ` Anshuman Khandual
2019-03-11 12:57           ` Anshuman Khandual
2019-03-11 23:11         ` Yu Zhao
2019-03-11 23:11           ` Yu Zhao
2019-03-11 23:11           ` Yu Zhao
2019-03-11  7:45     ` [PATCH v3 1/3] arm64: mm: use appropriate ctors for page tables Anshuman Khandual
2019-03-11  7:45       ` Anshuman Khandual
2019-03-11 23:23       ` Yu Zhao
2019-03-11 23:23         ` Yu Zhao
2019-03-12  0:57     ` [PATCH v4 1/4] " Yu Zhao
2019-03-12  0:57       ` Yu Zhao
2019-03-12  0:57       ` Yu Zhao
2019-03-12  0:57       ` [PATCH v4 2/4] arm64: mm: don't call page table ctors for init_mm Yu Zhao
2019-03-12  0:57         ` Yu Zhao
2019-03-12  0:57         ` Yu Zhao
2019-03-12  0:57       ` [PATCH v4 3/4] arm64: mm: call ctor for stage2 pmd page Yu Zhao
2019-03-12  0:57         ` Yu Zhao
2019-03-12  0:57         ` Yu Zhao
2019-03-12  2:19         ` Anshuman Khandual [this message]
2019-03-12  2:19           ` [PATCH] KVM: ARM: Remove pgtable page standard functions from stage-2 page tables Anshuman Khandual
2019-03-12  2:40           ` Yu Zhao
2019-03-12  2:40             ` Yu Zhao
2019-03-12 10:37           ` Suzuki K Poulose
2019-03-12 10:37             ` Suzuki K Poulose
2019-03-12 11:31             ` Anshuman Khandual
2019-03-12 11:31               ` Anshuman Khandual
2019-03-12 11:43               ` Suzuki K Poulose
2019-03-12 11:43                 ` Suzuki K Poulose
2019-03-12 13:25                 ` [PATCH V2] " Anshuman Khandual
2019-03-12 13:25                   ` Anshuman Khandual
2019-04-01 16:16                   ` Will Deacon
2019-04-01 16:16                     ` Will Deacon
2019-04-01 16:16                     ` Will Deacon
2019-04-01 18:34                     ` Yu Zhao
2019-04-01 18:34                       ` Yu Zhao
2019-04-01 18:34                       ` Yu Zhao
2019-04-02  9:03                       ` Will Deacon
2019-04-02  9:03                         ` Will Deacon
2019-04-02  9:03                         ` Will Deacon
2019-04-08 14:22                         ` Will Deacon
2019-04-08 14:22                           ` Will Deacon
2019-04-08 14:22                           ` Will Deacon
2019-04-08 14:22                           ` Will Deacon
2019-04-08 17:18                           ` Yu Zhao
2019-04-08 17:18                             ` Yu Zhao
2019-04-08 17:18                             ` Yu Zhao
2019-04-08  9:09                     ` Marc Zyngier
2019-04-08  9:09                       ` Marc Zyngier
2019-04-08  9:09                       ` Marc Zyngier
2019-04-08  9:09                       ` Marc Zyngier
2019-03-12  0:57       ` [PATCH v4 4/4] arm64: mm: enable per pmd page table lock Yu Zhao
2019-03-12  0:57         ` Yu Zhao
2019-03-12  0:57         ` Yu Zhao
2019-02-19  3:08 ` [PATCH] " Anshuman Khandual
2019-02-19  3:08   ` Anshuman Khandual

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1552357142-636-1-git-send-email-anshuman.khandual@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=will.deacon@arm.com \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.