Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kohei Enju <enju.kohei@fujitsu.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, maz@kernel.org,
	 will@kernel.org, catalin.marinas@arm.com,
	linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org, steven.price@arm.com,
	aneesh.kumar@kernel.org, oupton@kernel.org,  gshan@redhat.com,
	joey.gouly@arm.com, tabba@google.com, yuzenghui@huawei.com,
	 linux-coco@lists.linux.dev, gankulkarni@os.amperecomputing.com,
	sdonthineni@nvidia.com,  alpergun@google.com,
	fj0570is@fujitsu.com, WeiLin.Chang@arm.com,
	 lpieralisi@kernel.org, sudeep.holla@arm.com,
	jonathan.cameron@oss.qualcomm.com,
	 Soby Mathew <Soby.Mathew@arm.com>
Subject: Re: [PATCH v22 06/10] firmware: arm_rmm: Ensure the RMM has GPT entries for memory
Date: Fri, 23 Oct 2026 10:29:44 +0900	[thread overview]
Message-ID: <atq3Q7CBCmfzqzCL@FCCLS0092175.localdomain> (raw)
In-Reply-To: <0ab0d3a1-a225-4a88-91bf-04f8f0e42eb7@arm.com>

Hi Soby, Suzuki,

On 10/22 13:07, Suzuki K Poulose wrote:
> On 21/10/2026 15:00, Kohei Enju wrote:
> > On 10/21 14:35, Suzuki K Poulose wrote:
> > > Hi
> > > 
> > > On 21/10/2026 14:07, Kohei Enju wrote:
> > > > Hi Suzuki,
> > > > 
> > > > I've tested this series and found a possible TF-RMM issue.
> > > > Please  below.
> > > > 
> > > > On 10/02 07:15, Suzuki K Poulose wrote:
> > > > > From: Steven Price <steven.price@arm.com>
> > > > > 
> > > > > The RMM maintains the state of all the granules in the system to make
> > > > > sure that the host is abiding by the rules. This state can be maintained
> > > > > at different granularity, per page (TRACKING_FINE) or per region
> > > > > (TRACKING_COARSE or TRACKING_INTERMEDIATE). The region size depends on the
> > > > > underlying "RMI_GRANULE_SIZE". For a "coarse"/"intermediate" region,
> > > > > all pages in the region must be of the same state, this implies we need to
> > > > > have "fine" tracking for DRAM, so that we can delegate individual pages.
> > > > > 
> > > > > For now we only support a statically carved out memory for tracking
> > > > > granules for the "fine" regions. This can be extended in the future to
> > > > > allow modifying the tracking granularity and remove the need for a
> > > > > static allocation by the firmware.
> > > > > 
> > > > > Similarly, the firmware may create L0 GPT entries describing the total
> > > > > address space. But if we change the "PAS" (Physical Address Space) of a
> > > > > granule, then the firmware may need to create L1 tables to track the PAS
> > > > > at a finer granularity. Linux therefore checks if the platform firmware
> > > > > manages the PAR region. i.e., the firmware is in charge of managing the
> > > > > L1 GPTs (creation and the required memory for the GPT tables - via static
> > > > > carveouts) without host intervention. Support for dynamic GPT creation by
> > > > > the host will be added later.
> > > > > 
> > > > > If the firmware requires us to manage the tracking or GPT memory,
> > > > > deactivate the RMM and reclaim any memory donated at RMM activation.
> > > > > 
> > > > > Apply the same checks when hotplugged memory is brought online.
> > > > > 
> > > > > Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> > > > > Reviewed-by: Gavin Shan <gshan@redhat.com>
> > > > > Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> > > > > Tested-by: Gavin Shan <gshan@redhat.com>
> > > > > Signed-off-by: Steven Price <steven.price@arm.com>
> > > > > Co-developed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> > > > > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> > > > > ---
> > > > [...]
> > > > > +/*
> > > > > + * We do not support creating L1 GPTs yet. So, make sure that all the regions
> > > > > + * are managed by the firmware.
> > > > > + */
> > > > > +static int rmi_verify_gpt_firmware_managed(phys_addr_t start, phys_addr_t end)
> > > > > +{
> > > > > +	unsigned long l0gpt_sz;
> > > > > +	unsigned long next, par_state;
> > > > > +
> > > > > +	l0gpt_sz = 1UL << (30 + FIELD_GET(RMI_FEATURE_REGISTER_1_L0GPTSZ,
> > > > > +					  rmi_feat_reg(1)));
> > > > > +	start = ALIGN_DOWN(start, l0gpt_sz);
> > > > > +	end = ALIGN(end, l0gpt_sz);
> > > > > +
> > > > > +	while (start < end) {
> > > > > +		long ret = rmi_gpt_info(start, end, &next, &par_state);
> > > > > +
> > > > > +		if (ret != RMI_SUCCESS) {
> > > > > +			pr_err("RMI_GPT_INFO failed for %llx-%llx: (%ld)\n",
> > > > > +				start, end, ret);
> > > > > +			return -ENXIO;
> > > > > +		}
> > > > > +
> > > > > +		if (WARN_ON(next <= start))
> > > > > +			return -ENXIO;
> > > > > +
> > > > > +		if (par_state != RMI_GPT_PAR_PLAT) {
> > > > > +			pr_err("GPT for the region is not managed by firmware %llx-%lx\n",
> > > > > +				start, next);
> > > > > +			return -ENODEV;
> > > > 
> > > > When system RAM starts at a non-L0GPTSZ-aligned address, the alignment
> > > > in rmi_verify_gpt_firmware_managed() may cause the queried L0GPT range
> > > > to include a memory hole.
> > > 
> > > > 
> > > > On out platform, the relevant memory layout is:
> > > > 
> > > >       800c0000000-800dc3fffff : memory hole
> > > >       800dc400000-82fffffffff : System RAM
> > > > 
> > > 
> > > Thanks for the report.
> > > 
> > > > Consequently, Linux queries the following L0GPT range:
> > > > 
> > > >       800c0000000-80100000000
> > > > 
> > > > The query fails with RMI_GPT_PAR_RESERVED:
> > > > 
> > > >       [    8.551855] GPT for the region is not managed by firmware 800c0000000-80100000000
> > > > 
> > > > and arm64_init_rmi() subsequently fails.
> > > > 
> > > > As I understand it, smc_gpt_info() in TF-RMM checks only the beginning
> > > > of the aligned L0GPT range. Since that address is in the hole, the whole
> > > > range is reported as RMI_GPT_PAR_RESERVED, even though it contains
> > > > platform-managed System RAM.
> > > > 
> > > > I believe this should be addressed in TF-RMM. Do you have any thoughts
> > > > on the expected RMI_GPT_INFO behavior in this case?
> > > 
> > > I believe the RMM should report a value that represents the situation
> > > better. In this case, there is a hole, and some conventional memory
> > > areas. For the conventional memory, the RMM has to manage the GPTs.
> > > (This applies to the tf-RMM implementation of TRACKING Granule state
> > > too. It only looks at the first granule and reports the type of memory.)
> > > 
> > > RMI_GPT_PAR_RESERVED is not accurate as the memory region is not
> > > reserved, unless it is reserved for firmware (in which case the
> > > memory description is wrong).
> > > 
> > > I would say RMI_GPT_PAR_PLAT  is accurate if the L1GPT exists, as the
> > >   region covered by the L0GPT has some memory that are delegable.
> > > 
> > > Otherwise it must be reported as RMI_GPT_HOST_NOT_CREATED.
> > > 
> > > The information that a given memory region is not "memory" (i.e. hole)
> > > is basically TRACKING_STATE returned as RMI_MEM_CATEGORY_NONE
> > 
> > Thanks for the clarification. Could you please raise this with the TF-RMM
> > team? Please let me know if I can help with testing or provide any
> > additional information.
> 
> [Duplicating Soby's response, which may have been filtered due to the HTML
> email]

Thanks for relaying Soby's response :)

> 
> --->8---
> 
> Thanks Kohei for reporting this issue. I have pushed a fix for this in
> TF-RMM which we hope to get merged soon.
> 
> https://review.trustedfirmware.org/c/TF-RMM/tf-rmm/+/55689/1

Thank you for the quick fix! I'll check the patch and give it a try on our
platform.

Thanks,
Kohei

> 
> Best Regards
> Soby Mathew


  reply	other threads:[~2026-10-23  1:31 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02  6:14 [PATCH v22 00/10] firmware: arm_rmm: Add RMM v2.0 base RMI support Suzuki K Poulose
2026-10-02  6:14 ` [PATCH v22 01/10] firmware: arm_rmm: Add SMC definitions for calling the RMM Suzuki K Poulose
2026-10-02  6:14 ` [PATCH v22 02/10] firmware: arm_rmm: Check for RMI support at init Suzuki K Poulose
2026-10-13  3:53   ` Gavin Shan
2026-10-13  9:58     ` Suzuki K Poulose
2026-10-14  7:26       ` Gavin Shan
2026-10-14  9:19         ` Suzuki K Poulose
2026-10-14 10:58           ` Gavin Shan
2026-10-14 11:06             ` Sudeep Holla
2026-10-14 11:06             ` Suzuki K Poulose
2026-10-14 12:05               ` Sudeep Holla
2026-10-14 12:40                 ` Suzuki K Poulose
2026-10-02  6:14 ` [PATCH v22 03/10] firmware: arm_rmm: Configure the RMM with the host's page size Suzuki K Poulose
2026-10-02  6:15 ` [PATCH v22 04/10] firmware: arm_rmm: Add support for SRO Suzuki K Poulose
2026-10-02  6:15 ` [PATCH v22 05/10] firmware: arm_rmm: Activate the RMM Suzuki K Poulose
2026-10-02  6:15 ` [PATCH v22 06/10] firmware: arm_rmm: Ensure the RMM has GPT entries for memory Suzuki K Poulose
2026-10-21 13:07   ` Kohei Enju
2026-10-21 13:35     ` Suzuki K Poulose
2026-10-21 14:00       ` Kohei Enju
2026-10-22 12:07         ` Suzuki K Poulose
2026-10-23  1:29           ` Kohei Enju [this message]
2026-10-02  6:15 ` [PATCH v22 07/10] kernel: hibernate: Add an arch hook for preventing hiberation Suzuki K Poulose
2026-10-02 11:03   ` Catalin Marinas
2026-10-02 15:29     ` Suzuki K Poulose
2026-10-12 19:11     ` Rafael J. Wysocki (Intel)
2026-10-02 13:32   ` Sudeep Holla
2026-10-02  6:15 ` [PATCH v22 08/10] arm64: Block hibernate and kexec while RMM is active Suzuki K Poulose
2026-10-02  6:15 ` [PATCH v22 09/10] firmware: arm_rmm: Add wrappers for Realm related RMI commands Suzuki K Poulose
2026-10-02 11:05   ` Catalin Marinas
2026-10-02 15:28     ` Suzuki K Poulose
2026-10-02  6:15 ` [PATCH v22 10/10] firmware: arm_rmm: hotplug: Skip memory added to ZONE_MOVABLE Suzuki K Poulose
2026-10-02  7:57   ` David Hildenbrand (Arm)
2026-10-02 18:49 ` [PATCH v22 00/10] firmware: arm_rmm: Add RMM v2.0 base RMI support Catalin Marinas
2026-10-03  5:57   ` Suzuki K Poulose

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=atq3Q7CBCmfzqzCL@FCCLS0092175.localdomain \
    --to=enju.kohei@fujitsu.com \
    --cc=Soby.Mathew@arm.com \
    --cc=WeiLin.Chang@arm.com \
    --cc=alpergun@google.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=fj0570is@fujitsu.com \
    --cc=gankulkarni@os.amperecomputing.com \
    --cc=gshan@redhat.com \
    --cc=joey.gouly@arm.com \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sdonthineni@nvidia.com \
    --cc=steven.price@arm.com \
    --cc=sudeep.holla@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@google.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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