The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Drew Fustini" <fustini@kernel.org>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 5/8] riscv_cbqri: resctrl: Add cache allocation via capacity block mask
Date: Thu, 30 Jul 2026 01:27:22 +0000	[thread overview]
Message-ID: <20260730012722.A77E71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729-dfustini-atl-sc-cbqri-dt-v6-5-7c22b05d461b@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Capacity controllers registered after boot bypass capability validation, which can cause resctrl failures and hardware writes with out-of-bounds parameters.
--

--- Patch [5]: [PATCH v6 5/8] riscv_cbqri: resctrl: Add cache allocation via capacity block mask ---
commit b95a917a4c4e682ec805c748e42c4a7bedae47b2
Author: Drew Fustini <fustini@kernel.org>

    riscv_cbqri: resctrl: Add cache allocation via capacity block mask

This commit wires CBQRI capacity controllers into resctrl as RDT_RESOURCE_L2
and RDT_RESOURCE_L3 schemata. It handles domain creation during the cpuhp
online callback for offline CPUs, and defines context-switch and capability
checks for RISC-V.

> diff --git a/drivers/resctrl/cbqri_resctrl.c b/drivers/resctrl/cbqri_resctrl.c
> index 0000000000000..0c4bfa2a7f433
> --- /dev/null
> +++ b/drivers/resctrl/cbqri_resctrl.c
[ ... ]
> +static int cbqri_attach_cpu_to_all_ctrls(unsigned int cpu)
> +{
> +	static const u32 levels[] = { 2, 3 };
> +	struct cbqri_controller *ctrl, *c;
> +	struct cbqri_resctrl_res *hw_res;
> +	struct rdt_ctrl_domain *d;
> +	struct cacheinfo *ci;
> +	int i, rid;
[ ... ]
> +		/* The controller backing this CPU's cache at this level. */
> +		ctrl = NULL;
> +		list_for_each_entry(c, &cbqri_controllers, list) {
> +			if (c->type == CBQRI_CONTROLLER_TYPE_CAPACITY &&
> +			    c->alloc_capable &&
> +			    c->cache.cache_level == levels[i] &&
> +			    c->cache.cache_id == ci->id) {
> +				ctrl = c;
> +				break;
> +			}
> +		}
> +		if (!ctrl)
> +			continue;
> +
> +		d = cbqri_find_ctrl_domain(&hw_res->resctrl_res.ctrl_domains,
> +					   ci->id);
> +		if (d) {
> +			cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
> +			continue;
> +		}
> +
> +		d = cbqri_create_ctrl_domain(ctrl, &hw_res->resctrl_res, cpu,
> +					     ci->id);

[Severity: High]
Does this code allow a late-registered controller to bypass the capability
validation?

During boot, cbqri_resctrl_pick_caches() validates that all controllers at a
given cache level have identical capabilities (like ncblks and rcid_count)
using cbqri_cc_caps_agree().

However, in the CPU hotplug path, if a new cache controller is probed
after boot, cbqri_attach_cpu_to_all_ctrls() finds it and creates a
domain without verifying it matches the baseline hw_res->ctrl.

If the hotplugged controller has a smaller rcid_count than the baseline,
could resctrl assume the baseline capabilities and cause hardware
out-of-bounds writes by using an invalid RCID in
resctrl_arch_reset_all_ctrls()?

Would adding a call to cbqri_cc_caps_agree() here to compare the new
controller against hw_res->ctrl prevent this?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729-dfustini-atl-sc-cbqri-dt-v6-0-7c22b05d461b@kernel.org?part=5

  reply	other threads:[~2026-07-30  1:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30  1:11 [PATCH v6 0/8] riscv: Add Ssqosid and initial CBQRI resctrl support Drew Fustini
2026-07-30  1:11 ` [PATCH v6 1/8] dt-bindings: riscv: Add Ssqosid extension description Drew Fustini
2026-08-05  2:46   ` Paul Walmsley
2026-07-30  1:11 ` [PATCH v6 2/8] riscv: Detect the Ssqosid extension Drew Fustini
2026-08-05  2:47   ` Paul Walmsley
2026-08-05  3:40     ` Drew Fustini
2026-07-30  1:11 ` [PATCH v6 3/8] riscv: Add support for srmcfg CSR from " Drew Fustini
2026-07-30  1:22   ` sashiko-bot
2026-07-30  2:04     ` Drew Fustini
2026-08-05 18:54   ` Paul Walmsley
2026-08-05 20:50     ` Drew Fustini
2026-08-06  1:21       ` Paul Walmsley
2026-07-30  1:11 ` [PATCH v6 4/8] riscv_cbqri: Add capacity controller probe and allocation device ops Drew Fustini
2026-07-30  1:11 ` [PATCH v6 5/8] riscv_cbqri: resctrl: Add cache allocation via capacity block mask Drew Fustini
2026-07-30  1:27   ` sashiko-bot [this message]
2026-07-30  2:09     ` Drew Fustini
2026-07-30  1:11 ` [PATCH v6 6/8] riscv: Enable resctrl filesystem for Ssqosid Drew Fustini
2026-07-30  1:11 ` [PATCH v6 7/8] dt-bindings: riscv: Add binding for CBQRI controllers Drew Fustini
2026-07-30  1:11 ` [PATCH v6 8/8] riscv_cbqri: Add CBQRI capacity allocation platform driver Drew Fustini
2026-07-30  1:21   ` sashiko-bot
2026-07-30  2:11     ` Drew Fustini
2026-08-05  3:00 ` [PATCH v6 0/8] riscv: Add Ssqosid and initial CBQRI resctrl support patchwork-bot+linux-riscv
2026-08-05 19:00 ` patchwork-bot+linux-riscv

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=20260730012722.A77E71F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fustini@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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