Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: sashiko-reviews@lists.linux.dev, kvmarm@lists.linux.dev,
	kvm@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oupton@kernel.org>
Subject: Re: [PATCH v20 2/9] firmware: arm_rmm: Check for RMI support at init
Date: Wed, 30 Sep 2026 12:02:41 +0100	[thread overview]
Message-ID: <arzsUdIEVvafG-S5@arm.com> (raw)
In-Reply-To: <a2fa2bd1-6888-4ed5-9e2f-233eacb600a5@arm.com>

On Wed, Sep 30, 2026 at 09:18:48AM +0100, Suzuki K Poulose wrote:
> On 29/09/2026 23:28, sashiko-bot@kernel.org wrote:
> > > diff --git a/include/linux/arm-rmi-cmds.h b/include/linux/arm-rmi-cmds.h
> > > new file mode 100644
> > > index 0000000000000..911489b636522
> > > --- /dev/null
> > > +++ b/include/linux/arm-rmi-cmds.h
> > [ ... ]
> > > +static inline void rmi_smccc_invoke(struct arm_smccc_1_2_regs *regs)
> > > +{
> > > +	struct arm_smccc_1_2_regs args = *regs;
> > > +	long status;
> > > +	int i = 0;
> > > +
> > > +	while (i < RMM_BLOCKED_RETRY_COUNT) {
> > > +		arm_smccc_1_2_invoke(&args, regs);
> > > +
> > > +		status = RMI_RESULT_STATUS(regs->a0);
> > > +		if (status != RMI_BUSY && status != RMI_BLOCKED)
> > > +			break;
> > > +		if (status == RMI_BLOCKED)
> > > +			i++;
> > > +		cpu_relax();
> > > +	}
> > 
> > [Severity: High]
> > Does this sequence create an unbounded spin loop if the firmware continuously
> > returns RMI_BUSY?
> > 
> > If the status returned by arm_smccc_1_2_invoke() is RMI_BUSY, the loop
> > continues without incrementing the exit counter i. It issues cpu_relax()
> > but does not yield the CPU (e.g., via cond_resched()) or impose a timeout.
> > If the RMM firmware remains busy, this could cause the host kernel to lock
> > up indefinitely.
> 
> This is like "spinlock contention". RMM returns EBUSY when a resource is
> locked temporarily. We should be able to make progress, unlike the
> RMI_BLOCKED, which is blocking due to a long running operation.

I dug a bit into the RMI_BUSY description in the spec and it's not
always safe to spin forever. For RMI_{PDEV,VDEV}_COMMUNICATE, for
example, we need to return to the caller and retry later (for VDEV, the
spec suggests informing the realm). That's the TSM series, which doesn't
use the new API yet, but something to be aware of when it's updated.

We may need the spec to bound this spin anyway, or at least give an
indication that it's not forever, otherwise it affects latency,
especially in an RT kernel.

There's a generic RMI command return code table in B4.2 that lists
RMI_BUSY for an imp def reason for the command failing to make progress.
Does this apply to something like REC_ENTER? In the KVM series we call
that with IRQs masked.

We might need different APIs here: one for sleepable callers that does
cond_resched() (or backs off) while retrying, and one that returns
-EBUSY, e.g. for TSM, or for commands like REC_ENTER that we don't
expect to see RMI_BUSY and don't want to spin on.

-- 
Catalin

  reply	other threads:[~2026-09-30 11:02 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 22:16 [PATCH v20 0/9] firmware: arm_rmm: Add RMM v2.0 base RMI support Suzuki K Poulose
2026-09-29 22:16 ` [PATCH v20 1/9] firmware: arm_rmm: Add SMC definitions for calling the RMM Suzuki K Poulose
2026-09-30  9:51   ` Catalin Marinas
2026-09-29 22:16 ` [PATCH v20 2/9] firmware: arm_rmm: Check for RMI support at init Suzuki K Poulose
2026-09-29 22:28   ` sashiko-bot
2026-09-30  8:18     ` Suzuki K Poulose
2026-09-30 11:02       ` Catalin Marinas [this message]
2026-10-01  6:03         ` Suzuki K Poulose
2026-10-01  8:17           ` Suzuki K Poulose
2026-09-29 22:16 ` [PATCH v20 3/9] firmware: arm_rmm: Configure the RMM with the host's page size Suzuki K Poulose
2026-09-30 11:10   ` Catalin Marinas
2026-09-29 22:16 ` [PATCH v20 4/9] firmware: arm_rmm: Add support for SRO Suzuki K Poulose
2026-09-29 22:30   ` sashiko-bot
2026-09-30  8:45     ` Suzuki K Poulose
2026-09-30  8:46       ` Suzuki K Poulose
2026-09-30 13:15   ` Catalin Marinas
2026-09-30 13:48     ` Suzuki K Poulose
2026-09-29 22:16 ` [PATCH v20 5/9] firmware: arm_rmm: Activate the RMM Suzuki K Poulose
2026-09-30 13:20   ` Catalin Marinas
2026-09-29 22:16 ` [PATCH v20 6/9] firmware: arm_rmm: Ensure the RMM has GPT entries for memory Suzuki K Poulose
2026-09-30 13:39   ` Catalin Marinas
2026-09-30 14:44   ` Sudeep Holla
2026-09-30 15:55     ` Suzuki K Poulose
2026-10-01  8:31       ` Sudeep Holla
2026-09-29 22:16 ` [PATCH v20 7/9] arm64: Block hibernate and kexec while RMM is active Suzuki K Poulose
2026-09-29 22:26   ` sashiko-bot
2026-09-30  9:12     ` Suzuki K Poulose
2026-09-30 15:15       ` Catalin Marinas
2026-09-30 16:06   ` Jonathan Cameron
2026-09-29 22:16 ` [PATCH v20 8/9] firmware: arm_rmm: Add wrappers for Realm related RMI commands Suzuki K Poulose
2026-09-29 22:29   ` sashiko-bot
2026-09-30 11:12     ` Suzuki K Poulose
2026-09-30 15:51   ` Catalin Marinas
2026-09-29 22:16 ` [PATCH v20 9/9] firmware: arm_rmm: hotplug: Skip memory added to ZONE_MOVABLE Suzuki K Poulose
2026-09-30 12:22   ` David Hildenbrand (Arm)
2026-09-30 12:47     ` Suzuki K Poulose
2026-09-30 15:53   ` Catalin Marinas

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=arzsUdIEVvafG-S5@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=suzuki.poulose@arm.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