From: Alexandru Elisei <alexandru.elisei@arm.com> To: pbonzini@redhat.com, thuth@redhat.com, andrew.jones@linux.dev, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, nikos.nikoleris@arm.com Subject: [kvm-unit-tests RFC PATCH 08/19] arm/arm64: Use pgd_alloc() to allocate mmu_idmap Date: Tue, 9 Aug 2022 10:15:47 +0100 [thread overview] Message-ID: <20220809091558.14379-9-alexandru.elisei@arm.com> (raw) In-Reply-To: <20220809091558.14379-1-alexandru.elisei@arm.com> Until commit 031755dbfefb ("arm: enable vmalloc"), the idmap was allocated using pgd_alloc(). After that commit, all the page table allocator functions were switched to using the page allocator, but pgd_alloc() was left unchanged and became unused, with the idmap now being allocated with alloc_page(). For arm64, the pgd table size varies based on the page size, which is configured by the user. For arm, it will always contain 4 entries (it translates bits 31:30 of the input address). To keep things simple and consistent with the other functions and across both architectures, modify pgd_alloc() to use alloc_page() instead of memalign like the rest of the page table allocator functions and use it to allocate the idmap. Note that when the idmap is created, alloc_ops->memalign is memalign_pages() which allocates memory with page granularity. Using memalign() as before would still have allocated a full page. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- lib/arm/asm/pgtable.h | 4 ++-- lib/arm/mmu.c | 4 ++-- lib/arm64/asm/pgtable.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/arm/asm/pgtable.h b/lib/arm/asm/pgtable.h index d7c73906ba5e..a35f42965df9 100644 --- a/lib/arm/asm/pgtable.h +++ b/lib/arm/asm/pgtable.h @@ -43,8 +43,8 @@ #define pgd_free(pgd) free(pgd) static inline pgd_t *pgd_alloc(void) { - pgd_t *pgd = memalign(L1_CACHE_BYTES, PTRS_PER_PGD * sizeof(pgd_t)); - memset(pgd, 0, PTRS_PER_PGD * sizeof(pgd_t)); + assert(PTRS_PER_PGD * sizeof(pgd_t) <= PAGE_SIZE); + pgd_t *pgd = alloc_page(); return pgd; } diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index 8f936acafe8b..2b7405d0274f 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -165,7 +165,7 @@ void *setup_mmu(phys_addr_t unused0, void *unused1) #endif if (!mmu_idmap) - mmu_idmap = alloc_page(); + mmu_idmap = pgd_alloc(); for (r = mem_regions; r->end; ++r) { if (r->flags & MR_F_IO) { @@ -197,7 +197,7 @@ void __iomem *__ioremap(phys_addr_t phys_addr, size_t size) pgtable = current_thread_info()->pgtable; } else { if (!mmu_idmap) - mmu_idmap = alloc_page(); + mmu_idmap = pgd_alloc(); pgtable = mmu_idmap; } diff --git a/lib/arm64/asm/pgtable.h b/lib/arm64/asm/pgtable.h index bfb8a993e112..06357920aa74 100644 --- a/lib/arm64/asm/pgtable.h +++ b/lib/arm64/asm/pgtable.h @@ -49,8 +49,8 @@ #define pgd_free(pgd) free(pgd) static inline pgd_t *pgd_alloc(void) { - pgd_t *pgd = memalign(PAGE_SIZE, PTRS_PER_PGD * sizeof(pgd_t)); - memset(pgd, 0, PTRS_PER_PGD * sizeof(pgd_t)); + assert(PTRS_PER_PGD * sizeof(pgd_t) <= PAGE_SIZE); + pgd_t *pgd = alloc_page(); return pgd; } -- 2.37.1
WARNING: multiple messages have this Message-ID (diff)
From: Alexandru Elisei <alexandru.elisei@arm.com> To: pbonzini@redhat.com, thuth@redhat.com, andrew.jones@linux.dev, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, nikos.nikoleris@arm.com Subject: [kvm-unit-tests RFC PATCH 08/19] arm/arm64: Use pgd_alloc() to allocate mmu_idmap Date: Tue, 9 Aug 2022 10:15:47 +0100 [thread overview] Message-ID: <20220809091558.14379-9-alexandru.elisei@arm.com> (raw) In-Reply-To: <20220809091558.14379-1-alexandru.elisei@arm.com> Until commit 031755dbfefb ("arm: enable vmalloc"), the idmap was allocated using pgd_alloc(). After that commit, all the page table allocator functions were switched to using the page allocator, but pgd_alloc() was left unchanged and became unused, with the idmap now being allocated with alloc_page(). For arm64, the pgd table size varies based on the page size, which is configured by the user. For arm, it will always contain 4 entries (it translates bits 31:30 of the input address). To keep things simple and consistent with the other functions and across both architectures, modify pgd_alloc() to use alloc_page() instead of memalign like the rest of the page table allocator functions and use it to allocate the idmap. Note that when the idmap is created, alloc_ops->memalign is memalign_pages() which allocates memory with page granularity. Using memalign() as before would still have allocated a full page. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- lib/arm/asm/pgtable.h | 4 ++-- lib/arm/mmu.c | 4 ++-- lib/arm64/asm/pgtable.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/arm/asm/pgtable.h b/lib/arm/asm/pgtable.h index d7c73906ba5e..a35f42965df9 100644 --- a/lib/arm/asm/pgtable.h +++ b/lib/arm/asm/pgtable.h @@ -43,8 +43,8 @@ #define pgd_free(pgd) free(pgd) static inline pgd_t *pgd_alloc(void) { - pgd_t *pgd = memalign(L1_CACHE_BYTES, PTRS_PER_PGD * sizeof(pgd_t)); - memset(pgd, 0, PTRS_PER_PGD * sizeof(pgd_t)); + assert(PTRS_PER_PGD * sizeof(pgd_t) <= PAGE_SIZE); + pgd_t *pgd = alloc_page(); return pgd; } diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index 8f936acafe8b..2b7405d0274f 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -165,7 +165,7 @@ void *setup_mmu(phys_addr_t unused0, void *unused1) #endif if (!mmu_idmap) - mmu_idmap = alloc_page(); + mmu_idmap = pgd_alloc(); for (r = mem_regions; r->end; ++r) { if (r->flags & MR_F_IO) { @@ -197,7 +197,7 @@ void __iomem *__ioremap(phys_addr_t phys_addr, size_t size) pgtable = current_thread_info()->pgtable; } else { if (!mmu_idmap) - mmu_idmap = alloc_page(); + mmu_idmap = pgd_alloc(); pgtable = mmu_idmap; } diff --git a/lib/arm64/asm/pgtable.h b/lib/arm64/asm/pgtable.h index bfb8a993e112..06357920aa74 100644 --- a/lib/arm64/asm/pgtable.h +++ b/lib/arm64/asm/pgtable.h @@ -49,8 +49,8 @@ #define pgd_free(pgd) free(pgd) static inline pgd_t *pgd_alloc(void) { - pgd_t *pgd = memalign(PAGE_SIZE, PTRS_PER_PGD * sizeof(pgd_t)); - memset(pgd, 0, PTRS_PER_PGD * sizeof(pgd_t)); + assert(PTRS_PER_PGD * sizeof(pgd_t) <= PAGE_SIZE); + pgd_t *pgd = alloc_page(); return pgd; } -- 2.37.1 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2022-08-09 9:16 UTC|newest] Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-09 9:15 [kvm-unit-tests RFC PATCH 00/19] arm/arm64: Rework cache maintenance at boot Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 01/19] Makefile: Define __ASSEMBLY__ for assembly files Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 12:36 ` Nikos Nikoleris 2022-08-09 12:36 ` Nikos Nikoleris 2022-09-20 8:11 ` Andrew Jones 2022-09-20 8:11 ` Andrew Jones 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 02/19] lib/alloc_phys: Initialize align_min Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-09-20 8:20 ` Andrew Jones 2022-09-20 8:20 ` Andrew Jones 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 03/19] lib/alloc_phys: Use phys_alloc_aligned_safe and rename it to memalign_early Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-09-20 8:27 ` Andrew Jones 2022-09-20 8:27 ` Andrew Jones 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 04/19] powerpc: Use the page allocator Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 05/19] lib/alloc_phys: Remove locking Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-09-20 8:45 ` Andrew Jones 2022-09-20 8:45 ` Andrew Jones 2022-09-20 13:20 ` Alexandru Elisei 2022-09-20 13:20 ` Alexandru Elisei 2022-09-20 14:59 ` Andrew Jones 2022-09-20 14:59 ` Andrew Jones 2022-09-26 15:04 ` Alexandru Elisei 2022-09-26 15:04 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 06/19] lib/alloc_phys: Remove allocation accounting Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-09-20 8:40 ` Andrew Jones 2022-09-20 8:40 ` Andrew Jones 2022-09-20 13:19 ` Alexandru Elisei 2022-09-20 13:19 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 07/19] arm/arm64: Mark the phys_end parameter as unused in setup_mmu() Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-09-20 8:58 ` Andrew Jones 2022-09-20 8:58 ` Andrew Jones 2022-09-26 11:01 ` Alexandru Elisei 2022-09-26 11:01 ` Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei [this message] 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 08/19] arm/arm64: Use pgd_alloc() to allocate mmu_idmap Alexandru Elisei 2022-09-20 9:05 ` Andrew Jones 2022-09-20 9:05 ` Andrew Jones 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 09/19] arm/arm64: Zero secondary CPUs' stack Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 12:56 ` Nikos Nikoleris 2022-08-09 12:56 ` Nikos Nikoleris 2022-08-10 9:42 ` Alexandru Elisei 2022-08-10 9:42 ` Alexandru Elisei 2022-08-10 10:00 ` Nikos Nikoleris 2022-08-10 10:00 ` Nikos Nikoleris 2022-09-20 9:24 ` Andrew Jones 2022-09-20 9:24 ` Andrew Jones 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 10/19] arm/arm64: Enable the MMU early Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 11/19] arm/arm64: Map the UART when creating the translation tables Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 12/19] arm/arm64: assembler.h: Replace size with end address for dcache_by_line_op Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 13:01 ` Nikos Nikoleris 2022-08-09 13:01 ` Nikos Nikoleris 2022-09-20 9:37 ` Andrew Jones 2022-09-20 9:37 ` Andrew Jones 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 13/19] arm: page.h: Add missing libcflat.h include Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-09-20 9:39 ` Andrew Jones 2022-09-20 9:39 ` Andrew Jones 2022-09-26 11:02 ` Alexandru Elisei 2022-09-26 11:02 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 14/19] arm/arm64: Add C functions for doing cache maintenance Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 15/19] lib/alloc_phys: Add callback to perform " Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 16/19] arm/arm64: Allocate secondaries' stack using the page allocator Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-09-20 9:58 ` Andrew Jones 2022-09-20 9:58 ` Andrew Jones 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 17/19] arm/arm64: Configure secondaries' stack before enabling the MMU Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 18/19] arm/arm64: Perform dcache maintenance at boot Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 9:15 ` [kvm-unit-tests RFC PATCH 19/19] arm/arm64: Rework the cache maintenance in asm_mmu_disable Alexandru Elisei 2022-08-09 9:15 ` Alexandru Elisei 2022-08-09 13:53 ` Nikos Nikoleris 2022-08-09 13:53 ` Nikos Nikoleris 2022-08-09 14:22 ` Alexandru Elisei 2022-08-09 14:22 ` Alexandru Elisei 2022-08-09 15:53 ` Nikos Nikoleris 2022-08-09 15:53 ` Nikos Nikoleris 2022-08-09 16:53 ` Alexandru Elisei 2022-08-09 16:53 ` Alexandru Elisei 2022-08-09 19:48 ` Nikos Nikoleris 2022-08-09 19:48 ` Nikos Nikoleris 2022-08-10 8:52 ` Alexandru Elisei 2022-08-10 8:52 ` Alexandru Elisei 2022-08-09 9:49 ` [kvm-unit-tests RFC PATCH 00/19] arm/arm64: Rework cache maintenance at boot Alexandru Elisei 2022-08-09 9:49 ` Alexandru Elisei 2023-11-05 10:16 ` Alexandru Elisei 2023-11-06 9:37 ` Shaoqin Huang 2023-11-07 9:01 ` Alexandru Elisei
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=20220809091558.14379-9-alexandru.elisei@arm.com \ --to=alexandru.elisei@arm.com \ --cc=andrew.jones@linux.dev \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=nikos.nikoleris@arm.com \ --cc=pbonzini@redhat.com \ --cc=thuth@redhat.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: linkBe 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.