From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/5] arm64: mm: BUG on unsupported manipulations of live kernel mappings
Date: Wed, 12 Oct 2016 16:04:29 +0100 [thread overview]
Message-ID: <20161012150428.s4gajqlnnivo6bld@localhost> (raw)
In-Reply-To: <1476271425-19401-2-git-send-email-ard.biesheuvel@linaro.org>
On Wed, Oct 12, 2016 at 12:23:41PM +0100, Ard Biesheuvel wrote:
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -28,8 +28,6 @@
> #include <linux/memblock.h>
> #include <linux/fs.h>
> #include <linux/io.h>
> -#include <linux/slab.h>
> -#include <linux/stop_machine.h>
>
> #include <asm/barrier.h>
> #include <asm/cputype.h>
> @@ -95,6 +93,12 @@ static phys_addr_t __init early_pgtable_alloc(void)
> return phys;
> }
>
> +/*
> + * The following mapping attributes may be updated in live
> + * kernel mappings without the need for break-before-make.
> + */
> +static const pteval_t modifiable_attr_mask = PTE_PXN | PTE_RDONLY | PTE_WRITE;
> +
> static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
> unsigned long end, unsigned long pfn,
> pgprot_t prot,
> @@ -115,8 +119,18 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
>
> pte = pte_set_fixmap_offset(pmd, addr);
> do {
> + pte_t old_pte = *pte;
> +
> set_pte(pte, pfn_pte(pfn, prot));
> pfn++;
> +
> + /*
> + * After the PTE entry has been populated once, we
> + * only allow updates to the permission attributes.
> + */
> + BUG_ON(pte_val(old_pte) != 0 &&
> + ((pte_val(old_pte) ^ pte_val(*pte)) &
> + ~modifiable_attr_mask) != 0);
Please turn this check into a single macro. You have it in three places
already (though with different types but a macro would do). Something
like below (feel free to come up with a better macro name):
BUG_ON(!safe_pgattr_change(old_pte, *pte));
--
Catalin
next prev parent reply other threads:[~2016-10-12 15:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-12 11:23 [PATCH v3 0/5] arm64/mm: use the contiguous attribute for kernel mappings Ard Biesheuvel
2016-10-12 11:23 ` [PATCH v3 1/5] arm64: mm: BUG on unsupported manipulations of live " Ard Biesheuvel
2016-10-12 15:04 ` Catalin Marinas [this message]
2016-10-13 12:25 ` Ard Biesheuvel
2016-10-13 14:44 ` Catalin Marinas
2016-10-13 14:48 ` Ard Biesheuvel
2016-10-13 16:51 ` Catalin Marinas
2016-10-13 16:58 ` Ard Biesheuvel
2016-10-12 11:23 ` [PATCH v3 2/5] arm64: mm: replace 'block_mappings_allowed' with 'page_mappings_only' Ard Biesheuvel
2016-10-12 15:07 ` Mark Rutland
2016-10-12 11:23 ` [PATCH v3 3/5] arm64: mm: set the contiguous bit for kernel mappings where appropriate Ard Biesheuvel
2016-10-13 16:28 ` Catalin Marinas
2016-10-13 16:57 ` Ard Biesheuvel
2016-10-13 17:27 ` Catalin Marinas
2016-10-12 11:23 ` [PATCH v3 4/5] arm64: mm: support additional contiguous kernel mapping region sizes Ard Biesheuvel
2016-10-14 10:28 ` Catalin Marinas
2016-10-14 17:51 ` Ard Biesheuvel
2016-10-12 11:23 ` [PATCH v3 5/5] arm64: mm: round memstart_addr to contiguous PUD/PMD size 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=20161012150428.s4gajqlnnivo6bld@localhost \
--to=catalin.marinas@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox