* [Question] Memory attribute reserved by Device Tree? @ 2016-06-30 11:10 Masahiro Yamada 2016-06-30 11:39 ` Robin Murphy 0 siblings, 1 reply; 7+ messages in thread From: Masahiro Yamada @ 2016-06-30 11:10 UTC (permalink / raw) To: linux-arm-kernel, devicetree Hello. Which memory attribute will ARM/ARM64 Linux set to the memory region reserved by /memreserve/ of Device Tree? Normal memory non-cacheable? Or, cacheable? Or, not defined? Perhaps actual behavior depends on whether the reserved area is located in the low-memory region? Thanks, -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Question] Memory attribute reserved by Device Tree? 2016-06-30 11:10 [Question] Memory attribute reserved by Device Tree? Masahiro Yamada @ 2016-06-30 11:39 ` Robin Murphy [not found] ` <577504D7.7080106-5wv7dgnIgG8@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Robin Murphy @ 2016-06-30 11:39 UTC (permalink / raw) To: Masahiro Yamada, linux-arm-kernel, devicetree; +Cc: Mark Rutland On 30/06/16 12:10, Masahiro Yamada wrote: > Hello. > > Which memory attribute will ARM/ARM64 Linux > set to the memory region reserved by > /memreserve/ of Device Tree? > > > Normal memory non-cacheable? > Or, cacheable? > Or, not defined? > > Perhaps actual behavior depends on whether the reserved area is > located in the low-memory region? Isn't the point of memreserve that the kernel avoids mapping it at all? If a reserved region is later mapped in by a driver using dma_declare_coherent_memory(), ioremap(), memremap() or whatever else, then the attributes will vary depending on the exact method used. Robin. > > > Thanks, > > ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <577504D7.7080106-5wv7dgnIgG8@public.gmane.org>]
* Re: [Question] Memory attribute reserved by Device Tree? [not found] ` <577504D7.7080106-5wv7dgnIgG8@public.gmane.org> @ 2016-06-30 12:26 ` Mark Rutland 2016-07-06 4:10 ` Masahiro Yamada 0 siblings, 1 reply; 7+ messages in thread From: Mark Rutland @ 2016-06-30 12:26 UTC (permalink / raw) To: Robin Murphy Cc: Masahiro Yamada, linux-arm-kernel, devicetree-u79uwXL29TY76Z2rM5mHXA On Thu, Jun 30, 2016 at 12:39:03PM +0100, Robin Murphy wrote: > On 30/06/16 12:10, Masahiro Yamada wrote: > > Hello. > > > > Which memory attribute will ARM/ARM64 Linux > > set to the memory region reserved by > > /memreserve/ of Device Tree? > > > > > > Normal memory non-cacheable? > > Or, cacheable? > > Or, not defined? > > > > Perhaps actual behavior depends on whether the reserved area is > > located in the low-memory region? > > Isn't the point of memreserve that the kernel avoids mapping it at all? Not quite. A /memreserve/ allows the kernel to map a region, so long as it doesn't use the region for general allocation. While not strictly defined for arm64 today, in practice the kernel may map a region with Normal Inner-Shareable Inner-WB Outer-WB attributes, following similar behaviour for PPC as defined in ePAPR. Generally I would advise against the use of a memreserve, and favour carving memory out of memory nodes as required, as that imposes stricter requirements. > If a reserved region is later mapped in by a driver using > dma_declare_coherent_memory(), ioremap(), memremap() or whatever else, > then the attributes will vary depending on the exact method used. Indeed. This applies even with the above. Thanks, Mark. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Question] Memory attribute reserved by Device Tree? 2016-06-30 12:26 ` Mark Rutland @ 2016-07-06 4:10 ` Masahiro Yamada [not found] ` <CAK7LNAQJNYVFjZyMH=kU+VJLfUCr2EwKc51HB4knZ=XM7s+MQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Masahiro Yamada @ 2016-07-06 4:10 UTC (permalink / raw) To: Mark Rutland; +Cc: devicetree, Robin Murphy, linux-arm-kernel 2016-06-30 21:26 GMT+09:00 Mark Rutland <mark.rutland@arm.com>: > On Thu, Jun 30, 2016 at 12:39:03PM +0100, Robin Murphy wrote: >> On 30/06/16 12:10, Masahiro Yamada wrote: >> > Hello. >> > >> > Which memory attribute will ARM/ARM64 Linux >> > set to the memory region reserved by >> > /memreserve/ of Device Tree? >> > >> > >> > Normal memory non-cacheable? >> > Or, cacheable? >> > Or, not defined? >> > >> > Perhaps actual behavior depends on whether the reserved area is >> > located in the low-memory region? >> >> Isn't the point of memreserve that the kernel avoids mapping it at all? > > Not quite. A /memreserve/ allows the kernel to map a region, so long as > it doesn't use the region for general allocation. > > While not strictly defined for arm64 today, in practice the kernel may > map a region with Normal Inner-Shareable Inner-WB Outer-WB attributes, > following similar behaviour for PPC as defined in ePAPR. > > Generally I would advise against the use of a memreserve, and favour > carving memory out of memory nodes as required, as that imposes stricter > requirements. > >> If a reserved region is later mapped in by a driver using >> dma_declare_coherent_memory(), ioremap(), memremap() or whatever else, >> then the attributes will vary depending on the exact method used. > > Indeed. This applies even with the above. Hi Robin, Mark, Thanks for clarification! My motivation is to try my own implementation of PSCI for my ARMv7 SoC. I put my PSCI firmware somewhere in the DRAM region and protected it with /memreserve/, but I was not sure what kind of memory attribute is used for the area. -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CAK7LNAQJNYVFjZyMH=kU+VJLfUCr2EwKc51HB4knZ=XM7s+MQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [Question] Memory attribute reserved by Device Tree? [not found] ` <CAK7LNAQJNYVFjZyMH=kU+VJLfUCr2EwKc51HB4knZ=XM7s+MQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2016-07-06 5:34 ` Ard Biesheuvel [not found] ` <CAKv+Gu_iF31mBbg1pMawq+7fPDo4iXdGWJT_nWV4Oy+AqDpFOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Ard Biesheuvel @ 2016-07-06 5:34 UTC (permalink / raw) To: Masahiro Yamada Cc: Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Robin Murphy, linux-arm-kernel On 6 July 2016 at 06:10, Masahiro Yamada <yamada.masahiro-uWyLwvC0a2jby3iVrkZq2A@public.gmane.org> wrote: > 2016-06-30 21:26 GMT+09:00 Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>: >> On Thu, Jun 30, 2016 at 12:39:03PM +0100, Robin Murphy wrote: >>> On 30/06/16 12:10, Masahiro Yamada wrote: >>> > Hello. >>> > >>> > Which memory attribute will ARM/ARM64 Linux >>> > set to the memory region reserved by >>> > /memreserve/ of Device Tree? >>> > >>> > >>> > Normal memory non-cacheable? >>> > Or, cacheable? >>> > Or, not defined? >>> > >>> > Perhaps actual behavior depends on whether the reserved area is >>> > located in the low-memory region? >>> >>> Isn't the point of memreserve that the kernel avoids mapping it at all? >> >> Not quite. A /memreserve/ allows the kernel to map a region, so long as >> it doesn't use the region for general allocation. >> >> While not strictly defined for arm64 today, in practice the kernel may >> map a region with Normal Inner-Shareable Inner-WB Outer-WB attributes, >> following similar behaviour for PPC as defined in ePAPR. >> >> Generally I would advise against the use of a memreserve, and favour >> carving memory out of memory nodes as required, as that imposes stricter >> requirements. >> >>> If a reserved region is later mapped in by a driver using >>> dma_declare_coherent_memory(), ioremap(), memremap() or whatever else, >>> then the attributes will vary depending on the exact method used. >> >> Indeed. This applies even with the above. > > > Hi Robin, Mark, > > > Thanks for clarification! > > > My motivation is to try my own implementation of PSCI for my ARMv7 SoC. > > I put my PSCI firmware somewhere in the DRAM region and > protected it with /memreserve/, but I was not sure what kind of memory attribute > is used for the area. > As Mark implies, /memreserve/ entries are not suitable for this, and you should create an entry under /reserved-memory instead (please check the bindings under Documentation/ for details). This not only allows you to add a no-map attribute to prevent the kernel from mapping it (which allows you to map it any way you like), it also guarantees that the reservation is honoured even when booting via UEFI, as /memreserve/s are ignored in this case. Note that the difference between the handling of /memreserve/ and /reserved-memory under UEFI is arbitrary, and should be fixed imo. Original issue is here, as yet unresolved: http://thread.gmane.org/gmane.linux.kernel.efi/6464 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CAKv+Gu_iF31mBbg1pMawq+7fPDo4iXdGWJT_nWV4Oy+AqDpFOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [Question] Memory attribute reserved by Device Tree? [not found] ` <CAKv+Gu_iF31mBbg1pMawq+7fPDo4iXdGWJT_nWV4Oy+AqDpFOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2016-07-06 9:34 ` Mark Rutland 2016-07-06 9:48 ` Ard Biesheuvel 0 siblings, 1 reply; 7+ messages in thread From: Mark Rutland @ 2016-07-06 9:34 UTC (permalink / raw) To: Ard Biesheuvel Cc: Masahiro Yamada, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Robin Murphy, linux-arm-kernel On Wed, Jul 06, 2016 at 07:34:58AM +0200, Ard Biesheuvel wrote: > On 6 July 2016 at 06:10, Masahiro Yamada <yamada.masahiro-uWyLwvC0a2jby3iVrkZq2A@public.gmane.org> wrote: > > My motivation is to try my own implementation of PSCI for my ARMv7 SoC. > > > > I put my PSCI firmware somewhere in the DRAM region and > > protected it with /memreserve/, but I was not sure what kind of memory attribute > > is used for the area. > > As Mark implies, /memreserve/ entries are not suitable for this, and > you should create an entry under /reserved-memory instead (please > check the bindings under Documentation/ for details). I'd strongly recommend that the memory in question was carved out of the memory node, rather than using a reserved-memory node. The OS has absolutely no reason to know about this memory in the first place. This is more robust as other agents will similarly not poke the memory. > This not only allows you to add a no-map attribute to prevent the > kernel from mapping it (which allows you to map it any way you like), > it also guarantees that the reservation is honoured even when booting > via UEFI, as /memreserve/s are ignored in this case. You'll still need to teach your UEFI implementation to reserve the region (and to not give it cacheable attributes), to enable this, so similarly I'd recommend that it is completely removed from the memory map -- no agent other than the PSCI implementation has any reason to map this memory. Thanks, Mark. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Question] Memory attribute reserved by Device Tree? 2016-07-06 9:34 ` Mark Rutland @ 2016-07-06 9:48 ` Ard Biesheuvel 0 siblings, 0 replies; 7+ messages in thread From: Ard Biesheuvel @ 2016-07-06 9:48 UTC (permalink / raw) To: Mark Rutland Cc: Masahiro Yamada, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Robin Murphy, linux-arm-kernel On 6 July 2016 at 11:34, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> wrote: > On Wed, Jul 06, 2016 at 07:34:58AM +0200, Ard Biesheuvel wrote: >> On 6 July 2016 at 06:10, Masahiro Yamada <yamada.masahiro-uWyLwvC0a2jby3iVrkZq2A@public.gmane.org> wrote: >> > My motivation is to try my own implementation of PSCI for my ARMv7 SoC. >> > >> > I put my PSCI firmware somewhere in the DRAM region and >> > protected it with /memreserve/, but I was not sure what kind of memory attribute >> > is used for the area. >> >> As Mark implies, /memreserve/ entries are not suitable for this, and >> you should create an entry under /reserved-memory instead (please >> check the bindings under Documentation/ for details). > > I'd strongly recommend that the memory in question was carved out of the > memory node, rather than using a reserved-memory node. The OS has > absolutely no reason to know about this memory in the first place. > > This is more robust as other agents will similarly not poke the memory. > Right, so I misunderstood your suggestion. You'd prefer the memory in question not to be covered at all by any memory nodes. I agree this makes the most sense. >> This not only allows you to add a no-map attribute to prevent the >> kernel from mapping it (which allows you to map it any way you like), >> it also guarantees that the reservation is honoured even when booting >> via UEFI, as /memreserve/s are ignored in this case. > > You'll still need to teach your UEFI implementation to reserve the > region (and to not give it cacheable attributes), to enable this, You'd need this in any case if you are using UEFI, unless you're seeding its view of the memory map from the DT. So I think this is a separate issue. > so similarly I'd recommend that it is completely removed from the memory > map -- no agent other than the PSCI implementation has any reason to map > this memory. > Indeed. Since you are invoking PSCI via hvc or smc calls, neither the OS nor anything else that executes at the same exception level (or whatever we call it for ARMv7) has any business accessing it directly, and so it does not need to know of its existence. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-07-06 9:48 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-06-30 11:10 [Question] Memory attribute reserved by Device Tree? Masahiro Yamada 2016-06-30 11:39 ` Robin Murphy [not found] ` <577504D7.7080106-5wv7dgnIgG8@public.gmane.org> 2016-06-30 12:26 ` Mark Rutland 2016-07-06 4:10 ` Masahiro Yamada [not found] ` <CAK7LNAQJNYVFjZyMH=kU+VJLfUCr2EwKc51HB4knZ=XM7s+MQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-07-06 5:34 ` Ard Biesheuvel [not found] ` <CAKv+Gu_iF31mBbg1pMawq+7fPDo4iXdGWJT_nWV4Oy+AqDpFOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-07-06 9:34 ` Mark Rutland 2016-07-06 9:48 ` Ard Biesheuvel
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).