All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Anup Patel <anup@brainfault.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	devicetree@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v8 2/4] mm: Introduce memblock_isolate_memory
Date: Mon, 20 Mar 2023 19:44:00 +0200	[thread overview]
Message-ID: <ZBibYDR0h1UeL6L5@kernel.org> (raw)
In-Reply-To: <efe1ef6b-b1c2-8d5b-82b7-3cd64053643e@ghiti.fr>

On Mon, Mar 20, 2023 at 11:54:14AM +0100, Alexandre Ghiti wrote:
> Hi Mike,
> 
> On 3/16/23 21:12, Mike Rapoport wrote:
> > Hi Alexandre,
> > 
> > On Thu, Mar 16, 2023 at 02:17:09PM +0100, Alexandre Ghiti wrote:
> > > This function allows to split a region in memblock.memory and will be
> > > useful when setting up the linear mapping with STRICT_KERNEL_RWX: it
> > > allows to isolate the kernel text/rodata and then avoid to map those
> > > regions with a PUD/P4D/PGD.
> > Sorry I've missed it last time. The changelog is fine in the context of
> 
> 
> No worries :)
> 
> 
> > this series, but if you look at it as a part of memblock changelog it
> > doesn't provide enough background on why memblock_isolate_memory() is
> > useful.
> > 
> > Can you please add more context so it would be self explanatory?
> 
> 
> What about: "memblock.memory contains the list of memory regions and a
> memory region can cover memory that will be mapped with different
> permissions. So to ease the mapping process, allow to isolate those regions
> by introducing a new function called memblock_isolate_memory. This will be
> used in arch specific code to isolate the kernel text/rodata regions when
> STRICT_KERNEL_RWX is enabled so that we avoid mapping them with PUD/P4D/PGD
> mappings."

With this change

... STRICT_KERNEL_RWX is enabled so that they can be mapped with base pages.

Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>

> Thanks,
> 
> Alex
> 
> 
> > 
> > > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > > Reviewed-by: Anup Patel <anup@brainfault.org>
> > > Tested-by: Anup Patel <anup@brainfault.org>
> > > ---
> > >   include/linux/memblock.h |  1 +
> > >   mm/memblock.c            | 20 ++++++++++++++++++++
> > >   2 files changed, 21 insertions(+)
> > > 
> > > diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> > > index 50ad19662a32..2f7ef97c0da7 100644
> > > --- a/include/linux/memblock.h
> > > +++ b/include/linux/memblock.h
> > > @@ -125,6 +125,7 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);
> > >   int memblock_mark_mirror(phys_addr_t base, phys_addr_t size);
> > >   int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
> > >   int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
> > > +int memblock_isolate_memory(phys_addr_t base, phys_addr_t size);
> > >   void memblock_free_all(void);
> > >   void memblock_free(void *ptr, size_t size);
> > > diff --git a/mm/memblock.c b/mm/memblock.c
> > > index 25fd0626a9e7..e8c651a37012 100644
> > > --- a/mm/memblock.c
> > > +++ b/mm/memblock.c
> > > @@ -805,6 +805,26 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type,
> > >   	return 0;
> > >   }
> > > +/**
> > > + * memblock_isolate_memory - isolate given range in memblock.memory
> > > + * @base: base of range to isolate
> > > + * @size: size of range to isolate
> > > + *
> > > + * Isolates the given range in memblock.memory so that it does not share any
> > > + * region with other ranges.
> > > + *
> > > + * Return:
> > > + * 0 on success, -errno on failure.
> > > + */
> > > +
> > > +int __init_memblock memblock_isolate_memory(phys_addr_t base, phys_addr_t size)
> > > +{
> > > +	int start_rgn, end_rgn;
> > > +
> > > +	return memblock_isolate_range(&memblock.memory, base, size,
> > > +				      &start_rgn, &end_rgn);
> > > +}
> > > +
> > >   static int __init_memblock memblock_remove_range(struct memblock_type *type,
> > >   					  phys_addr_t base, phys_addr_t size)
> > >   {
> > > -- 
> > > 2.37.2
> > > 
> 

-- 
Sincerely yours,
Mike.

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Mike Rapoport <rppt@kernel.org>
To: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Anup Patel <anup@brainfault.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	devicetree@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v8 2/4] mm: Introduce memblock_isolate_memory
Date: Mon, 20 Mar 2023 19:44:00 +0200	[thread overview]
Message-ID: <ZBibYDR0h1UeL6L5@kernel.org> (raw)
In-Reply-To: <efe1ef6b-b1c2-8d5b-82b7-3cd64053643e@ghiti.fr>

On Mon, Mar 20, 2023 at 11:54:14AM +0100, Alexandre Ghiti wrote:
> Hi Mike,
> 
> On 3/16/23 21:12, Mike Rapoport wrote:
> > Hi Alexandre,
> > 
> > On Thu, Mar 16, 2023 at 02:17:09PM +0100, Alexandre Ghiti wrote:
> > > This function allows to split a region in memblock.memory and will be
> > > useful when setting up the linear mapping with STRICT_KERNEL_RWX: it
> > > allows to isolate the kernel text/rodata and then avoid to map those
> > > regions with a PUD/P4D/PGD.
> > Sorry I've missed it last time. The changelog is fine in the context of
> 
> 
> No worries :)
> 
> 
> > this series, but if you look at it as a part of memblock changelog it
> > doesn't provide enough background on why memblock_isolate_memory() is
> > useful.
> > 
> > Can you please add more context so it would be self explanatory?
> 
> 
> What about: "memblock.memory contains the list of memory regions and a
> memory region can cover memory that will be mapped with different
> permissions. So to ease the mapping process, allow to isolate those regions
> by introducing a new function called memblock_isolate_memory. This will be
> used in arch specific code to isolate the kernel text/rodata regions when
> STRICT_KERNEL_RWX is enabled so that we avoid mapping them with PUD/P4D/PGD
> mappings."

With this change

... STRICT_KERNEL_RWX is enabled so that they can be mapped with base pages.

Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>

> Thanks,
> 
> Alex
> 
> 
> > 
> > > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > > Reviewed-by: Anup Patel <anup@brainfault.org>
> > > Tested-by: Anup Patel <anup@brainfault.org>
> > > ---
> > >   include/linux/memblock.h |  1 +
> > >   mm/memblock.c            | 20 ++++++++++++++++++++
> > >   2 files changed, 21 insertions(+)
> > > 
> > > diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> > > index 50ad19662a32..2f7ef97c0da7 100644
> > > --- a/include/linux/memblock.h
> > > +++ b/include/linux/memblock.h
> > > @@ -125,6 +125,7 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);
> > >   int memblock_mark_mirror(phys_addr_t base, phys_addr_t size);
> > >   int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
> > >   int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
> > > +int memblock_isolate_memory(phys_addr_t base, phys_addr_t size);
> > >   void memblock_free_all(void);
> > >   void memblock_free(void *ptr, size_t size);
> > > diff --git a/mm/memblock.c b/mm/memblock.c
> > > index 25fd0626a9e7..e8c651a37012 100644
> > > --- a/mm/memblock.c
> > > +++ b/mm/memblock.c
> > > @@ -805,6 +805,26 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type,
> > >   	return 0;
> > >   }
> > > +/**
> > > + * memblock_isolate_memory - isolate given range in memblock.memory
> > > + * @base: base of range to isolate
> > > + * @size: size of range to isolate
> > > + *
> > > + * Isolates the given range in memblock.memory so that it does not share any
> > > + * region with other ranges.
> > > + *
> > > + * Return:
> > > + * 0 on success, -errno on failure.
> > > + */
> > > +
> > > +int __init_memblock memblock_isolate_memory(phys_addr_t base, phys_addr_t size)
> > > +{
> > > +	int start_rgn, end_rgn;
> > > +
> > > +	return memblock_isolate_range(&memblock.memory, base, size,
> > > +				      &start_rgn, &end_rgn);
> > > +}
> > > +
> > >   static int __init_memblock memblock_remove_range(struct memblock_type *type,
> > >   					  phys_addr_t base, phys_addr_t size)
> > >   {
> > > -- 
> > > 2.37.2
> > > 
> 

-- 
Sincerely yours,
Mike.

WARNING: multiple messages have this Message-ID (diff)
From: Mike Rapoport <rppt@kernel.org>
To: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Anup Patel <anup@brainfault.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	devicetree@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v8 2/4] mm: Introduce memblock_isolate_memory
Date: Mon, 20 Mar 2023 19:44:00 +0200	[thread overview]
Message-ID: <ZBibYDR0h1UeL6L5@kernel.org> (raw)
In-Reply-To: <efe1ef6b-b1c2-8d5b-82b7-3cd64053643e@ghiti.fr>

On Mon, Mar 20, 2023 at 11:54:14AM +0100, Alexandre Ghiti wrote:
> Hi Mike,
> 
> On 3/16/23 21:12, Mike Rapoport wrote:
> > Hi Alexandre,
> > 
> > On Thu, Mar 16, 2023 at 02:17:09PM +0100, Alexandre Ghiti wrote:
> > > This function allows to split a region in memblock.memory and will be
> > > useful when setting up the linear mapping with STRICT_KERNEL_RWX: it
> > > allows to isolate the kernel text/rodata and then avoid to map those
> > > regions with a PUD/P4D/PGD.
> > Sorry I've missed it last time. The changelog is fine in the context of
> 
> 
> No worries :)
> 
> 
> > this series, but if you look at it as a part of memblock changelog it
> > doesn't provide enough background on why memblock_isolate_memory() is
> > useful.
> > 
> > Can you please add more context so it would be self explanatory?
> 
> 
> What about: "memblock.memory contains the list of memory regions and a
> memory region can cover memory that will be mapped with different
> permissions. So to ease the mapping process, allow to isolate those regions
> by introducing a new function called memblock_isolate_memory. This will be
> used in arch specific code to isolate the kernel text/rodata regions when
> STRICT_KERNEL_RWX is enabled so that we avoid mapping them with PUD/P4D/PGD
> mappings."

With this change

... STRICT_KERNEL_RWX is enabled so that they can be mapped with base pages.

Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>

> Thanks,
> 
> Alex
> 
> 
> > 
> > > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > > Reviewed-by: Anup Patel <anup@brainfault.org>
> > > Tested-by: Anup Patel <anup@brainfault.org>
> > > ---
> > >   include/linux/memblock.h |  1 +
> > >   mm/memblock.c            | 20 ++++++++++++++++++++
> > >   2 files changed, 21 insertions(+)
> > > 
> > > diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> > > index 50ad19662a32..2f7ef97c0da7 100644
> > > --- a/include/linux/memblock.h
> > > +++ b/include/linux/memblock.h
> > > @@ -125,6 +125,7 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);
> > >   int memblock_mark_mirror(phys_addr_t base, phys_addr_t size);
> > >   int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
> > >   int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
> > > +int memblock_isolate_memory(phys_addr_t base, phys_addr_t size);
> > >   void memblock_free_all(void);
> > >   void memblock_free(void *ptr, size_t size);
> > > diff --git a/mm/memblock.c b/mm/memblock.c
> > > index 25fd0626a9e7..e8c651a37012 100644
> > > --- a/mm/memblock.c
> > > +++ b/mm/memblock.c
> > > @@ -805,6 +805,26 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type,
> > >   	return 0;
> > >   }
> > > +/**
> > > + * memblock_isolate_memory - isolate given range in memblock.memory
> > > + * @base: base of range to isolate
> > > + * @size: size of range to isolate
> > > + *
> > > + * Isolates the given range in memblock.memory so that it does not share any
> > > + * region with other ranges.
> > > + *
> > > + * Return:
> > > + * 0 on success, -errno on failure.
> > > + */
> > > +
> > > +int __init_memblock memblock_isolate_memory(phys_addr_t base, phys_addr_t size)
> > > +{
> > > +	int start_rgn, end_rgn;
> > > +
> > > +	return memblock_isolate_range(&memblock.memory, base, size,
> > > +				      &start_rgn, &end_rgn);
> > > +}
> > > +
> > >   static int __init_memblock memblock_remove_range(struct memblock_type *type,
> > >   					  phys_addr_t base, phys_addr_t size)
> > >   {
> > > -- 
> > > 2.37.2
> > > 
> 

-- 
Sincerely yours,
Mike.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-03-20 17:44 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 13:17 [PATCH v8 0/4] riscv: Use PUD/P4D/PGD pages for the linear mapping Alexandre Ghiti
2023-03-16 13:17 ` Alexandre Ghiti
2023-03-16 13:17 ` Alexandre Ghiti
2023-03-16 13:17 ` [PATCH v8 1/4] riscv: Get rid of riscv_pfn_base variable Alexandre Ghiti
2023-03-16 13:17   ` Alexandre Ghiti
2023-03-16 13:17   ` Alexandre Ghiti
2023-03-16 13:17 ` [PATCH v8 2/4] mm: Introduce memblock_isolate_memory Alexandre Ghiti
2023-03-16 13:17   ` Alexandre Ghiti
2023-03-16 13:17   ` Alexandre Ghiti
2023-03-16 20:12   ` Mike Rapoport
2023-03-16 20:12     ` Mike Rapoport
2023-03-16 20:12     ` Mike Rapoport
2023-03-20 10:54     ` Alexandre Ghiti
2023-03-20 10:54       ` Alexandre Ghiti
2023-03-20 10:54       ` Alexandre Ghiti
2023-03-20 17:44       ` Mike Rapoport [this message]
2023-03-20 17:44         ` Mike Rapoport
2023-03-20 17:44         ` Mike Rapoport
2023-03-23 11:52         ` Alexandre Ghiti
2023-03-23 11:52           ` Alexandre Ghiti
2023-03-23 11:52           ` Alexandre Ghiti
2023-03-23 12:16           ` Mike Rapoport
2023-03-23 12:16             ` Mike Rapoport
2023-03-23 12:16             ` Mike Rapoport
2023-03-23 12:30             ` Alexandre Ghiti
2023-03-23 12:30               ` Alexandre Ghiti
2023-03-23 12:30               ` Alexandre Ghiti
2023-03-16 13:17 ` [PATCH v8 3/4] arm64: Make use of memblock_isolate_memory for the linear mapping Alexandre Ghiti
2023-03-16 13:17   ` Alexandre Ghiti
2023-03-16 13:17   ` Alexandre Ghiti
2023-03-24 15:21   ` Will Deacon
2023-03-24 15:21     ` Will Deacon
2023-03-24 15:21     ` Will Deacon
2023-03-24 15:23     ` Alexandre Ghiti
2023-03-24 15:23       ` Alexandre Ghiti
2023-03-24 15:23       ` Alexandre Ghiti
2023-03-16 13:17 ` [PATCH v8 4/4] riscv: Use PUD/P4D/PGD pages " Alexandre Ghiti
2023-03-16 13:17   ` Alexandre Ghiti
2023-03-16 13:17   ` Alexandre Ghiti
2023-03-23 12:18 ` [PATCH v8 0/4] " Anup Patel
2023-03-23 12:18   ` Anup Patel
2023-03-23 12:18   ` Anup Patel
2023-03-23 12:54   ` Alexandre Ghiti
2023-03-23 12:54     ` Alexandre Ghiti
2023-03-23 12:54     ` Alexandre Ghiti
2023-03-23 14:55     ` Anup Patel
2023-03-23 14:55       ` Anup Patel
2023-03-23 14:55       ` Anup Patel
2023-03-24  9:59       ` Alexandre Ghiti
2023-03-24  9:59         ` Alexandre Ghiti
2023-03-24  9:59         ` Alexandre Ghiti
     [not found]         ` <CAPqJEFr6MgUyARfbWAo7EeQKLVd4xRJz_LOYN68UC-kPD1Hr5A@mail.gmail.com>
2024-01-18  8:23           ` Fwd: " Nylon Chen
2024-01-18  8:23             ` Nylon Chen
2024-01-18  8:23             ` Nylon Chen
2024-01-18 13:01             ` Alexandre Ghiti
2024-01-18 13:01               ` Alexandre Ghiti
2024-01-18 13:01               ` Alexandre Ghiti
2024-01-19  9:26               ` Nylon Chen
2024-01-19  9:26                 ` Nylon Chen
2024-01-19  9:26                 ` Nylon Chen
2024-02-05  9:32                 ` Alexandre Ghiti
2024-02-05  9:32                   ` Alexandre Ghiti
2024-02-05  9:32                   ` Alexandre Ghiti
2024-03-12  6:40                   ` Nylon Chen
2024-03-12  6:40                     ` Nylon Chen
2024-03-12  6:40                     ` Nylon Chen
2024-03-12  6:48                     ` Nylon Chen
2024-03-12  6:48                       ` Nylon Chen
2024-03-12  6:48                       ` Nylon Chen
2024-03-12  9:33                       ` Alexandre Ghiti
2024-03-12  9:33                         ` Alexandre Ghiti
2024-03-12  9:33                         ` Alexandre Ghiti

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=ZBibYDR0h1UeL6L5@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=alexghiti@rivosinc.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh+dt@kernel.org \
    --cc=will@kernel.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.