From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: allow vmalloc regions to be set with set_memory_*
Date: Mon, 18 Jan 2016 15:05:56 +0000 [thread overview]
Message-ID: <20160118150556.GO21067@leverpostej> (raw)
In-Reply-To: <1453125665-26627-1-git-send-email-ard.biesheuvel@linaro.org>
On Mon, Jan 18, 2016 at 03:01:05PM +0100, Ard Biesheuvel wrote:
> The range of set_memory_* is currently restricted to the module address
> range because of difficulties in breaking down larger block sizes.
> vmalloc maps PAGE_SIZE pages so it is safe to use as well. Update the
> function ranges and add a comment explaining why the range is restricted
> the way it is.
>
> Suggested-by: Laura Abbott <labbott@fedoraproject.org>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Previously we allowed set_memory_* calls on any range in the modules
area (even if that covered multiple VMAs). However, I believe that given
the way vmap area is allocated, no caller can rely on mappings being
adjacent, and thus such calls would be erroneous.
Given that, this looks good to me (with one minor nit below). FWIW:
Acked-by: Mark Rutland <mark.rutland@arm.com>
> ---
> arch/arm64/mm/pageattr.c | 23 +++++++++++++++++++----
> 1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
> index 3571c7309c5e..1360a02d88b7 100644
> --- a/arch/arm64/mm/pageattr.c
> +++ b/arch/arm64/mm/pageattr.c
> @@ -13,6 +13,7 @@
> #include <linux/kernel.h>
> #include <linux/mm.h>
> #include <linux/module.h>
> +#include <linux/vmalloc.h>
> #include <linux/sched.h>
Nit: please keep alphabetical order here.
Mark.
>
> #include <asm/pgtable.h>
> @@ -44,6 +45,7 @@ static int change_memory_common(unsigned long addr, int numpages,
> unsigned long end = start + size;
> int ret;
> struct page_change_data data;
> + struct vm_struct *area;
>
> if (!PAGE_ALIGNED(addr)) {
> start &= PAGE_MASK;
> @@ -51,10 +53,23 @@ static int change_memory_common(unsigned long addr, int numpages,
> WARN_ON_ONCE(1);
> }
>
> - if (start < MODULES_VADDR || start >= MODULES_END)
> - return -EINVAL;
> -
> - if (end < MODULES_VADDR || end >= MODULES_END)
> + /*
> + * Kernel VA mappings are always live, and splitting live section
> + * mappings into page mappings may cause TLB conflicts. This means
> + * we have to ensure that changing the permission bits of the range
> + * we are operating on does not result in such splitting.
> + *
> + * Let's restrict ourselves to mappings created by vmalloc (or vmap).
> + * Those are guaranteed to consist entirely of page mappings, and
> + * splitting is never needed.
> + *
> + * So check whether the [addr, addr + size) interval is entirely
> + * covered by precisely one VM area that has the VM_ALLOC flag set.
> + */
> + area = find_vm_area((void *)addr);
> + if (!area ||
> + end > (unsigned long)area->addr + area->size ||
> + !(area->flags & VM_ALLOC))
> return -EINVAL;
>
> data.set_mask = set_mask;
> --
> 2.5.0
>
next prev parent reply other threads:[~2016-01-18 15:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-18 14:01 [PATCH] arm64: allow vmalloc regions to be set with set_memory_* Ard Biesheuvel
2016-01-18 15:05 ` Mark Rutland [this message]
2016-01-28 15:08 ` Will Deacon
2016-01-28 16:40 ` Ard Biesheuvel
2016-01-28 16:43 ` Ard Biesheuvel
2016-01-28 18:10 ` Will Deacon
2016-01-28 19:07 ` Ard Biesheuvel
-- strict thread matches above, loose matches on Subject: below --
2016-01-12 21:46 [PATCH] arm64: Allow " Laura Abbott
2016-01-13 0:01 ` Alexei Starovoitov
2016-01-13 0:31 ` Daniel Borkmann
2016-01-13 14:03 ` Ard Biesheuvel
2016-01-13 16:10 ` Ard Biesheuvel
2016-01-14 23:01 ` Laura Abbott
2016-01-18 11:56 ` Mark Rutland
2016-01-28 1:47 ` Xishi Qiu
2016-01-28 10:51 ` Mark Rutland
2016-01-28 11:47 ` Xishi Qiu
2016-01-28 14:27 ` Mark Rutland
2016-01-29 1:21 ` Xishi Qiu
2016-01-29 11:02 ` Mark Rutland
2016-01-30 2:48 ` Xishi Qiu
2016-02-03 13:43 ` Mark Rutland
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=20160118150556.GO21067@leverpostej \
--to=mark.rutland@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;
as well as URLs for NNTP newsgroup(s).