From: Mike Rapoport <rppt@kernel.org>
To: Peng Fan <peng.fan@nxp.com>
Cc: Ard Biesheuvel <ardb@kernel.org>,
"Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [PATCH 2/2] arm64: mm: support bootparam max_addr
Date: Wed, 15 Dec 2021 11:24:01 +0200 [thread overview]
Message-ID: <Ybm0MWDhzkkwAZoz@kernel.org> (raw)
In-Reply-To: <DU0PR04MB94179C41295FF369E5D755D488769@DU0PR04MB9417.eurprd04.prod.outlook.com>
On Wed, Dec 15, 2021 at 07:59:45AM +0000, Peng Fan wrote:
> > Subject: Re: [PATCH 2/2] arm64: mm: support bootparam max_addr
> >
> > On Wed, 15 Dec 2021 at 07:56, Peng Fan (OSS) <peng.fan@oss.nxp.com>
> > wrote:
> > >
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > There is a "mem=[x]" boot parameter, but when there is a whole
> > > reserved by secure TEE, the continuous DRAM area is split with two
> > memblocks.
> > >
> > > For example, DRAM area [0x40000000, 0xffffffff], when TEE uses
> > > [0x50000000, 0x51000000), the memblock will be split into [0x40000000,
> > > 0x50000000) and [0x51000000, 0xffffffff].
> > >
> > > If pass "mem=1024MB", the actually max addr will be 0x81000000.
> > > However if need the max addr be 0x80000000, mem=1008MB should be
> > used.
> > >
> > > There also might be multiple other holes that no visible to Linux,
> > > when we wanna to limit the max addr usable by Linux, using
> > > "max_addr=[X]" is much easier than "mem=[X]"
> > >
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> >
> > mem= is a hack already, please don't add another one. Limiting the memory
> > like this is far too tricky, given that the kernel itself and the initrd could end up
> > in memory that is excluded, and we have to go and fix things up if that
> > happens.
>
> We wanna to use the reserved memory with request_mem_region, but with
> commit 86588296acbfb1 ("fdt: Properly handle "no-map" field in the memory region ")
>
> request_mem_region will fail, because the reserved memory are now as
> kernel memory.
request_mem_region() is for MMIO. Why do you want to use it for RAM?
> So we use "mem=X" to work around the issue, but "mem=X" is not user friendly
> compared with "max_addr=" when there are multiple holes used by others.
>
> Thanks,
> Peng.
>
> >
> >
> > > ---
> > > arch/arm64/mm/init.c | 21 +++++++++++++++++++++
> > > 1 file changed, 21 insertions(+)
> > >
> > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index
> > > db63cc885771..3364b5e7a7fe 100644
> > > --- a/arch/arm64/mm/init.c
> > > +++ b/arch/arm64/mm/init.c
> > > @@ -173,6 +173,7 @@ int pfn_is_map_memory(unsigned long pfn)
> > > EXPORT_SYMBOL(pfn_is_map_memory);
> > >
> > > static phys_addr_t memory_limit __ro_after_init = PHYS_ADDR_MAX;
> > > +static phys_addr_t max_addr __ro_after_init = PHYS_ADDR_MAX;
> > >
> > > /*
> > > * Limit the memory size that was specified via FDT.
> > > @@ -189,6 +190,18 @@ static int __init early_mem(char *p) }
> > > early_param("mem", early_mem);
> > >
> > > +static int __init set_max_addr(char *p) {
> > > + if (!p)
> > > + return 1;
> > > +
> > > + max_addr = memparse(p, &p) & PAGE_MASK;
> > > + pr_notice("Memory max addr set to 0x%llx\n", max_addr);
> > > +
> > > + return 0;
> > > +}
> > > +early_param("max_addr", set_max_addr);
> > > +
> > > void __init arm64_memblock_init(void) {
> > > s64 linear_region_size = PAGE_END -
> > > _PAGE_OFFSET(vabits_actual); @@ -253,6 +266,9 @@ void __init
> > arm64_memblock_init(void)
> > > memblock_add(__pa_symbol(_text), (u64)(_end -
> > _text));
> > > }
> > >
> > > + if (max_addr != PHYS_ADDR_MAX)
> > > + memblock_cap_memory_range(0, max_addr);
> > > +
> > > if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size)
> > {
> > > /*
> > > * Add back the memory we just removed if it results
> > > in the @@ -427,4 +443,9 @@ void dump_mem_limit(void)
> > > } else {
> > > pr_emerg("Memory Limit: none\n");
> > > }
> > > +
> > > + if (max_addr != PHYS_ADDR_MAX)
> > > + pr_emerg("Max addr: 0x%llx\n", max_addr);
> > > + else
> > > + pr_emerg("Max addr: none\n");
> > > }
> > > --
> > > 2.25.1
> > >
> > >
> > > _______________________________________________
> > > linux-arm-kernel mailing list
> > > linux-arm-kernel@lists.infradead.org
> > > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists
> > > .infradead.org%2Fmailman%2Flistinfo%2Flinux-arm-kernel&data=04%
> > 7C0
> > >
> > 1%7Cpeng.fan%40nxp.com%7C3ad0ef697ad64542556208d9bf9d1e1f%7C68
> > 6ea1d3bc
> > >
> > 2b4c6fa92cd99c5c301635%7C0%7C0%7C637751503805222488%7CUnknow
> > n%7CTWFpbG
> > >
> > Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6
> > Mn0%
> > >
> > 3D%7C3000&sdata=iKVO4PUPnaRr%2B5gHcXxaaRxBt%2BK%2Fjytg8eQ
> > dCqgqh5o%
> > > 3D&reserved=0
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2021-12-15 9:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-15 6:45 [PATCH 1/2] arm64: mm: apply __ro_after_init to memory_limit Peng Fan (OSS)
2021-12-15 6:45 ` [PATCH 2/2] arm64: mm: support bootparam max_addr Peng Fan (OSS)
2021-12-15 7:32 ` Ard Biesheuvel
2021-12-15 7:59 ` Peng Fan
2021-12-15 9:24 ` Mike Rapoport [this message]
2021-12-15 9:30 ` Peng Fan
2021-12-15 9:53 ` Mike Rapoport
2021-12-15 12:05 ` Peng Fan
2021-12-16 14:19 ` Mike Rapoport
2021-12-15 7:30 ` [PATCH 1/2] arm64: mm: apply __ro_after_init to memory_limit Ard Biesheuvel
2021-12-15 10:02 ` David Hildenbrand
2022-01-20 15:56 ` (subset) " Catalin Marinas
2022-01-21 2:28 ` Anshuman Khandual
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=Ybm0MWDhzkkwAZoz@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=david@redhat.com \
--cc=geert+renesas@glider.be \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®