From: labbott@redhat.com (Laura Abbott)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 13/18] arm64: mm: add functions to walk tables in fixmap
Date: Mon, 4 Jan 2016 14:49:46 -0800 [thread overview]
Message-ID: <568AF70A.6020004@redhat.com> (raw)
In-Reply-To: <1451930211-22460-14-git-send-email-mark.rutland@arm.com>
On 01/04/2016 09:56 AM, Mark Rutland wrote:
> As a prepratory step to allow us to allocate early page tables from
> unmapped memory using memblock_alloc, add new p??_fixmap* functions that
> can be used to walk page tables outside of the linear mapping by using
> fixmap slots.
>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Jeremy Linton <jeremy.linton@arm.com>
> Cc: Laura Abbott <labbott@fedoraproject.org>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
> arch/arm64/include/asm/fixmap.h | 10 ++++++++++
> arch/arm64/include/asm/pgtable.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 36 insertions(+)
>
> diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h
> index 3097045..1a617d4 100644
> --- a/arch/arm64/include/asm/fixmap.h
> +++ b/arch/arm64/include/asm/fixmap.h
> @@ -62,6 +62,16 @@ enum fixed_addresses {
>
> FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
> FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
> +
> + /*
> + * Used for kernel page table creation, so unmapped memory may be used
> + * for tables.
> + */
> + FIX_PTE,
> + FIX_PMD,
> + FIX_PUD,
> + FIX_PGD,
> +
> __end_of_fixed_addresses
> };
>
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index f5742db..824e7f0 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -57,6 +57,7 @@
>
> #ifndef __ASSEMBLY__
>
> +#include <asm/fixmap.h>
> #include <linux/mmdebug.h>
>
> extern void __pte_error(const char *file, int line, unsigned long val);
> @@ -442,6 +443,10 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
> #define pte_unmap(pte) do { } while (0)
> #define pte_unmap_nested(pte) do { } while (0)
>
> +#define pte_fixmap(addr) ((pte_t *)set_fixmap_offset(FIX_PTE, addr))
> +#define pte_fixmap_offset(pmd, addr) pte_fixmap(pte_offset_phys(pmd, addr))
> +#define pte_fixmap_unmap() clear_fixmap(FIX_PTE)
> +
> #define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK))
>
> /*
> @@ -481,12 +486,21 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
> #define pmd_offset_phys(dir, addr) (pud_page_paddr(*(dir)) + pmd_index(addr) * sizeof(pmd_t))
> #define pmd_offset(dir, addr) ((pmd_t *)__va(pmd_offset_phys((dir), (addr))))
>
> +#define pmd_fixmap(addr) ((pmd_t *)set_fixmap_offset(FIX_PMD, addr))
> +#define pmd_fixmap_offset(pud, addr) pmd_fixmap(pmd_offset_phys(pud, addr))
> +#define pmd_fixmap_unmap() clear_fixmap(FIX_PMD)
> +
> #define pud_page(pud) pfn_to_page(__phys_to_pfn(pud_val(pud) & PHYS_MASK))
>
> #else
>
> #define pud_page_paddr(pud) ({ BUILD_BUG(); 0; })
>
> +/* Match pmd_offset folding in <asm/generic/pgtable-nopmd.h> */
> +#define pmd_fixmap(addr) NULL
> +#define pmd_fixmap_offset(pudp, addr) ((pmd_t *)pudp)
> +#define pmd_fixmap_unmap()
> +
> #endif /* CONFIG_PGTABLE_LEVELS > 2 */
>
> #if CONFIG_PGTABLE_LEVELS > 3
> @@ -519,12 +533,21 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
> #define pud_offset_phys(dir, addr) (pgd_page_paddr(*(dir)) + pud_index(addr) * sizeof(pud_t))
> #define pud_offset(dir, addr) ((pud_t *)__va(pud_offset_phys((dir), (addr))))
>
> +#define pud_fixmap(addr) ((pud_t *)set_fixmap_offset(FIX_PUD, addr))
> +#define pud_fixmap_offset(pgd, addr) pud_fixmap(pmd_offset_phys(pgd, addr))
> +#define pud_fixmap_unmap() clear_fixmap(FIX_PUD)
> +
> #define pgd_page(pgd) pfn_to_page(__phys_to_pfn(pgd_val(pgd) & PHYS_MASK))
>
> #else
>
> #define pgd_page_paddr(pgd) ({ BUILD_BUG(); 0;})
>
> +/* Match pud_offset folding in <asm/generic/pgtable-nopud.h> */
> +#define pud_fixmap(addr) NULL
> +#define pud_fixmap_offset(pgdp, addr) ((pud_t *)pgdp)
> +#define pud_fixmap_unmap()
> +
> #endif /* CONFIG_PGTABLE_LEVELS > 3 */
>
> #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd))
> @@ -539,6 +562,9 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
> /* to find an entry in a kernel page-table-directory */
> #define pgd_offset_k(addr) pgd_offset(&init_mm, addr)
>
> +#define pgd_fixmap(addr) ((pgd_t *)set_fixmap_offset(FIX_PGD, addr))
> +#define pgd_fixmap_unmap() clear_fixmap(FIX_PGD)
> +
> static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
> {
> const pteval_t mask = PTE_USER | PTE_PXN | PTE_UXN | PTE_RDONLY |
>
Bikeshed: p??_fixmap_offset doesn't make it obvious that this is an
operation with a side effect. It seems more similar to
p??_offset_kernel which is read only. Perhaps it's the lack of set/map
in the name.
Thanks,
Laura
next prev parent reply other threads:[~2016-01-04 22:49 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-04 17:56 [PATCHv2 00/18] arm64: mm: rework page table creation Mark Rutland
2016-01-04 17:56 ` [PATCHv2 01/18] asm-generic: make __set_fixmap_offset a static inline Mark Rutland
2016-01-19 11:55 ` Mark Rutland
2016-01-19 14:11 ` Arnd Bergmann
2016-01-19 14:18 ` Mark Rutland
2016-01-28 15:10 ` Will Deacon
2016-01-04 17:56 ` [PATCHv2 02/18] arm64: mm: specialise pagetable allocators Mark Rutland
2016-01-04 17:56 ` [PATCHv2 03/18] arm64: mm: place empty_zero_page in bss Mark Rutland
2016-01-04 17:56 ` [PATCHv2 04/18] arm64: unify idmap removal Mark Rutland
2016-01-04 17:56 ` [PATCHv2 05/18] arm64: unmap idmap earlier Mark Rutland
2016-01-04 17:56 ` [PATCHv2 06/18] arm64: add function to install the idmap Mark Rutland
2016-01-04 17:56 ` [PATCHv2 07/18] arm64: mm: add code to safely replace TTBR1_EL1 Mark Rutland
2016-01-05 15:22 ` Catalin Marinas
2016-01-05 15:45 ` Mark Rutland
2016-01-04 17:56 ` [PATCHv2 08/18] arm64: kasan: avoid TLB conflicts Mark Rutland
2016-01-04 17:56 ` [PATCHv2 09/18] arm64: mm: move pte_* macros Mark Rutland
2016-01-04 17:56 ` [PATCHv2 10/18] arm64: mm: add functions to walk page tables by PA Mark Rutland
2016-01-04 17:56 ` [PATCHv2 11/18] arm64: mm: avoid redundant __pa(__va(x)) Mark Rutland
2016-01-04 17:56 ` [PATCHv2 12/18] arm64: mm: add __{pud,pgd}_populate Mark Rutland
2016-01-04 17:56 ` [PATCHv2 13/18] arm64: mm: add functions to walk tables in fixmap Mark Rutland
2016-01-04 22:49 ` Laura Abbott [this message]
2016-01-05 11:08 ` Mark Rutland
2016-01-04 17:56 ` [PATCHv2 14/18] arm64: mm: use fixmap when creating page tables Mark Rutland
2016-01-04 22:38 ` Laura Abbott
2016-01-05 10:40 ` Mark Rutland
2016-01-04 17:56 ` [PATCHv2 15/18] arm64: mm: allocate pagetables anywhere Mark Rutland
2016-01-04 17:56 ` [PATCHv2 16/18] arm64: mm: allow passing a pgdir to alloc_init_* Mark Rutland
2016-01-04 17:56 ` [PATCHv2 17/18] arm64: ensure _stext and _etext are page-aligned Mark Rutland
2016-01-04 17:56 ` [PATCHv2 18/18] arm64: mm: create new fine-grained mappings at boot Mark Rutland
2016-01-05 1:08 ` [PATCHv2 00/18] arm64: mm: rework page table creation Laura Abbott
2016-01-05 11:54 ` Mark Rutland
2016-01-05 18:36 ` Laura Abbott
2016-01-05 18:58 ` Mark Rutland
2016-01-05 19:17 ` Laura Abbott
2016-01-06 11:10 ` Mark Rutland
2016-01-08 19:15 ` Mark Rutland
2016-01-06 10:24 ` Catalin Marinas
2016-01-06 11:36 ` Mark Rutland
2016-01-06 14:23 ` Ard Biesheuvel
2016-01-18 14:47 ` Ard Biesheuvel
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=568AF70A.6020004@redhat.com \
--to=labbott@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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.