From: Xander <xandermoerkerken@gmail.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Mark Rutland <mark.rutland@arm.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Xander Moerkerken <xander.moerkerken@omron.com>
Subject: Re: [PATCH] Added ability to vmalloc executable memory
Date: Fri, 9 Dec 2022 14:51:19 +0100 [thread overview]
Message-ID: <CAGkG8RFW2=rLVtUmCOMPoTf2LP9WbQsYFLfJ3Dy17DV99Uza1A@mail.gmail.com> (raw)
In-Reply-To: <ed1c32c0-e882-e7f8-3acf-0c0204fb96ae@csgroup.eu>
On Fri, 9 Dec 2022 at 14:46, Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
>
>
> Le 09/12/2022 à 14:38, Xander a écrit :
> >
> > The pgprot parameter got removed because, according to the commit log,
> > for no other apparent reason than it being called with 'PAGE_KERNEL' as
> > an argument in the whole kernel. Therefore it got removed.
> > This removed the ability to allocate virtual memory with executing rights.
> > My use case comes from ioremap().
> > I think this is useful for others too.
> >
> > I don't see why this pgprot parameter got removed but this is the
> > alternative to reverting it to the older 5.7 function.
>
> Please avoid top-posting, and use only plain text.
>
> I think you don't answer to Mark's question.
>
> You are adding a new function that no driver uses apparently. If you are
> working on some piece of code that needs this new fonction, you can send
> this patch as part of a patch series including that code.
>
> By the way, when you need executable memory, the fonction to use is
> module_alloc(), that's the only function that garanties real executable
> memory on all platforms. For instance, on some powerpc, setting the X
> bit is not enough to get executable memory in vmalloc space.
>
> Christophe
>
Loud and clear, thanks for the feedback.
> >
> > On Fri, 9 Dec 2022 at 14:17, Mark Rutland <mark.rutland@arm.com
> > <mailto:mark.rutland@arm.com>> wrote:
> >
> > On Fri, Dec 09, 2022 at 02:10:52PM +0100, Xander Moerkerken wrote:
> > > From: Xander Moerkerken <xander.moerkerken@gmail.com
> > <mailto:xander.moerkerken@gmail.com>>
> > >
> > > Since release 5.8-rc1 the pgprot got removed from __vmalloc
> > > because the only usage was PAGE_KERNEL as argument.
> > > However, this removes the ability to input other arguments
> > > such as 'PAGE_KERNEL_EXEC', which can be used to allocate
> > > memory in which you can execute. For this reason a new
> > > function is introduced called '__vmalloc_exec'.
> > >
> > > Signed-off-by: Xander Moerkerken <xander.moerkerken@omron.com
> > <mailto:xander.moerkerken@omron.com>>
> >
> > What is this going to be used for? There's no user from this patch
> > alone, as a
> > module or otherwise.
> >
> > Mark.
> >
> > > ---
> > > include/linux/vmalloc.h | 1 +
> > > mm/vmalloc.c | 8 ++++++++
> > > 2 files changed, 9 insertions(+)
> > >
> > > diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> > > index 096d48aa3437..10c46513b6b2 100644
> > > --- a/include/linux/vmalloc.h
> > > +++ b/include/linux/vmalloc.h
> > > @@ -147,6 +147,7 @@ extern void *vzalloc_node(unsigned long size,
> > int node) __alloc_size(1);
> > > extern void *vmalloc_32(unsigned long size) __alloc_size(1);
> > > extern void *vmalloc_32_user(unsigned long size) __alloc_size(1);
> > > extern void *__vmalloc(unsigned long size, gfp_t gfp_mask)
> > __alloc_size(1);
> > > +extern void *__vmalloc_exec(unsigned long size, gfp_t gfp_mask)
> > __alloc_size(1);
> > > extern void *__vmalloc_node_range(unsigned long size, unsigned
> > long align,
> > > unsigned long start, unsigned long end,
> > gfp_t gfp_mask,
> > > pgprot_t prot, unsigned long vm_flags, int
> > node,
> > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > > index ccaa461998f3..8fd01ed7082b 100644
> > > --- a/mm/vmalloc.c
> > > +++ b/mm/vmalloc.c
> > > @@ -3294,6 +3294,14 @@ void *__vmalloc(unsigned long size, gfp_t
> > gfp_mask)
> > > }
> > > EXPORT_SYMBOL(__vmalloc);
> > >
> > > +
> > > +void *__vmalloc_exec(unsigned long size, gfp_t gfp_mask)
> > > +{
> > > + return __vmalloc_node_prot(size, 1, gfp_mask, PAGE_KERNEL_EXEC,
> > > + NUMA_NO_NODE,
> > __builtin_return_address(0));
> > > +}
> > > +EXPORT_SYMBOL(__vmalloc_exec);
> > > +
> > > /**
> > > * vmalloc - allocate virtually contiguous memory
> > > * @size: allocation size
> > > --
> > > 2.37.2
> > >
> >
next prev parent reply other threads:[~2022-12-09 13:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 13:10 Xander Moerkerken
2022-12-09 13:17 ` Mark Rutland
2022-12-09 13:38 ` Xander
2022-12-09 13:46 ` Christophe Leroy
2022-12-09 13:51 ` Xander [this message]
2022-12-09 14:17 ` Mark Rutland
2022-12-09 14:18 ` kernel test robot
2022-12-09 16:10 ` kernel test robot
2022-12-09 19:01 ` kernel test robot
2022-12-12 8:41 ` Christoph Hellwig
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='CAGkG8RFW2=rLVtUmCOMPoTf2LP9WbQsYFLfJ3Dy17DV99Uza1A@mail.gmail.com' \
--to=xandermoerkerken@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=xander.moerkerken@omron.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox