linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: unmap memory regions in /memreserve node
@ 2021-11-24 13:33 Calvin Zhang
  2021-11-30 22:43 ` Rob Herring
  0 siblings, 1 reply; 4+ messages in thread
From: Calvin Zhang @ 2021-11-24 13:33 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand; +Cc: devicetree, linux-kernel, Calvin Zhang

Reserved memory regions in /memreserve node aren't and shouldn't
be referenced elsewhere. So mark them no-map to skip direct mapping
for them.

Signed-off-by: Calvin Zhang <calvinzhang.cool@gmail.com>
---
 drivers/of/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index bdca35284ceb..9e88cc8445f6 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -638,7 +638,7 @@ void __init early_init_fdt_scan_reserved_mem(void)
 		fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
 		if (!size)
 			break;
-		early_init_dt_reserve_memory_arch(base, size, false);
+		early_init_dt_reserve_memory_arch(base, size, true);
 	}
 
 	fdt_scan_reserved_mem();
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] of: unmap memory regions in /memreserve node
  2021-11-24 13:33 [PATCH] of: unmap memory regions in /memreserve node Calvin Zhang
@ 2021-11-30 22:43 ` Rob Herring
  2021-12-02  9:25   ` Mark Rutland
  0 siblings, 1 reply; 4+ messages in thread
From: Rob Herring @ 2021-11-30 22:43 UTC (permalink / raw)
  To: Calvin Zhang; +Cc: Frank Rowand, devicetree, linux-kernel, linuxppc-dev

+linuxppc-dev

On Wed, Nov 24, 2021 at 09:33:47PM +0800, Calvin Zhang wrote:
> Reserved memory regions in /memreserve node aren't and shouldn't
> be referenced elsewhere. So mark them no-map to skip direct mapping
> for them.

I suspect this has a high chance of breaking some platform. There's no 
rule a region can't be accessed.

> 
> Signed-off-by: Calvin Zhang <calvinzhang.cool@gmail.com>
> ---
>  drivers/of/fdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index bdca35284ceb..9e88cc8445f6 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -638,7 +638,7 @@ void __init early_init_fdt_scan_reserved_mem(void)
>  		fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
>  		if (!size)
>  			break;
> -		early_init_dt_reserve_memory_arch(base, size, false);
> +		early_init_dt_reserve_memory_arch(base, size, true);
>  	}
>  
>  	fdt_scan_reserved_mem();
> -- 
> 2.30.2
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] of: unmap memory regions in /memreserve node
  2021-11-30 22:43 ` Rob Herring
@ 2021-12-02  9:25   ` Mark Rutland
  2021-12-03  1:11     ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Rutland @ 2021-12-02  9:25 UTC (permalink / raw)
  To: Rob Herring
  Cc: Calvin Zhang, Frank Rowand, devicetree, linux-kernel, linuxppc-dev

On Tue, Nov 30, 2021 at 04:43:31PM -0600, Rob Herring wrote:
> +linuxppc-dev
> 
> On Wed, Nov 24, 2021 at 09:33:47PM +0800, Calvin Zhang wrote:
> > Reserved memory regions in /memreserve node aren't and shouldn't
> > be referenced elsewhere. So mark them no-map to skip direct mapping
> > for them.
> 
> I suspect this has a high chance of breaking some platform. There's no 
> rule a region can't be accessed.

The subtlety is that the region shouldn't be explicitly accessed (e.g.
modified), but the OS is permitted to have the region mapped. In ePAPR this is
described as:

   This requirement is necessary because the client program is permitted to map
   memory with storage attributes specified as not Write Through Required, not
   Caching Inhibited, and Memory Coherence Required (i.e., WIMG = 0b001x), and
   VLE=0 where supported. The client program may use large virtual pages that
   contain reserved memory. However, the client program may not modify reserved
   memory, so the boot program may perform accesses to reserved memory as Write
   Through Required where conflicting values for this storage attribute are
   architecturally permissible.

Historically arm64 relied upon this for spin-table to work, and I *think* we
might not need that any more I agree that there's a high chance this will break
something (especially on 16K or 64K page size kernels), so I'd prefer to leave
it as-is.

If someone requires no-map behaviour, they should use a /reserved-memory entry
with a no-map property, which will work today and document their requirement
explicitly.

Thanks,
Mark.

> > Signed-off-by: Calvin Zhang <calvinzhang.cool@gmail.com>
> > ---
> >  drivers/of/fdt.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > index bdca35284ceb..9e88cc8445f6 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -638,7 +638,7 @@ void __init early_init_fdt_scan_reserved_mem(void)
> >  		fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> >  		if (!size)
> >  			break;
> > -		early_init_dt_reserve_memory_arch(base, size, false);
> > +		early_init_dt_reserve_memory_arch(base, size, true);
> >  	}
> >  
> >  	fdt_scan_reserved_mem();
> > -- 
> > 2.30.2
> > 
> > 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] of: unmap memory regions in /memreserve node
  2021-12-02  9:25   ` Mark Rutland
@ 2021-12-03  1:11     ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2021-12-03  1:11 UTC (permalink / raw)
  To: Mark Rutland, Rob Herring
  Cc: Calvin Zhang, Frank Rowand, devicetree, linux-kernel, linuxppc-dev

Mark Rutland <mark.rutland@arm.com> writes:
> On Tue, Nov 30, 2021 at 04:43:31PM -0600, Rob Herring wrote:
>> +linuxppc-dev
 
Sorry missed this until now ...

>> On Wed, Nov 24, 2021 at 09:33:47PM +0800, Calvin Zhang wrote:
>> > Reserved memory regions in /memreserve node aren't and shouldn't
>> > be referenced elsewhere. So mark them no-map to skip direct mapping
>> > for them.
>> 
>> I suspect this has a high chance of breaking some platform. There's no 
>> rule a region can't be accessed.
>
> The subtlety is that the region shouldn't be explicitly accessed (e.g.
> modified),

I think "modified" is the key there, reserved means Linux doesn't use
the range for its own data, but may still read from whatever is in the
range.

On some platforms the initrd will be marked as reserved, which Linux
obviously needs to read from.

> but the OS is permitted to have the region mapped. In ePAPR this is
> described as:
>
>    This requirement is necessary because the client program is permitted to map
>    memory with storage attributes specified as not Write Through Required, not
>    Caching Inhibited, and Memory Coherence Required (i.e., WIMG = 0b001x), and
>    VLE=0 where supported. The client program may use large virtual pages that
>    contain reserved memory. However, the client program may not modify reserved
>    memory, so the boot program may perform accesses to reserved memory as Write
>    Through Required where conflicting values for this storage attribute are
>    architecturally permissible.
>
> Historically arm64 relied upon this for spin-table to work, and I *think* we
> might not need that any more I agree that there's a high chance this will break
> something (especially on 16K or 64K page size kernels), so I'd prefer to leave
> it as-is.

Yeah I agree. On powerpc we still use large pages for the linear mapping
(direct map), so reserved regions will be incidentally mapped as
described above.

> If someone requires no-map behaviour, they should use a /reserved-memory entry
> with a no-map property, which will work today and document their requirement
> explicitly.

+1.

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-03  1:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 13:33 [PATCH] of: unmap memory regions in /memreserve node Calvin Zhang
2021-11-30 22:43 ` Rob Herring
2021-12-02  9:25   ` Mark Rutland
2021-12-03  1:11     ` Michael Ellerman

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).