From: <dan.j.williams@intel.com>
To: <alison.schofield@intel.com>, Davidlohr Bueso <dave@stgolabs.net>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
"Vishal Verma" <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
"Dan Williams" <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH] cxl/port: Validate decoder nr_targets against supported ways
Date: Wed, 13 Aug 2025 17:57:50 -0700 [thread overview]
Message-ID: <689d348e41a66_2709100cb@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20250813214218.2917555-1-alison.schofield@intel.com>
alison.schofield@ wrote:
> From: Alison Schofield <alison.schofield@intel.com>
>
> nr_targets is the number of downstream ports in a decoder's target
> list. It is limited to the supported interleave ways: 1, 2, 3, 4, 6,
> 8, 12, 16. The existing check only enforces nr_targets <=
> CXL_DECODER_MAX_INTERLEAVE (16), allowing invalid values, like 5, 7,
> etc, to pass through.
>
> Add is_nr_targets_valid() to check for supported interleave ways using
> ways_to_eiw(). Use it before allocating a decoder to avoid alloc/free
> churn when nr_targets is already known to be invalid.
>
> This was found by inspection and hardens the code.
Well, now seeing this and trying to answer the risk question in 1/ led
to me to reconsider whether this is a good idea and whether we have a
deeper confusion at play:
1/ "Hardening" needs to come with an actual risk claim. For
cxl_switch_decoder_alloc() the values come from hardware or ACPI and if
those are buggy all bets are off. ACPI is already protected by a
eiw_to_ways() conversion prior to calling cxl_root_decoder_alloc(), and
hardware is even more accurate than this
approach because it considers interleave ways capability.
2/ nr_targets != ways. ways_to_eiw() is the wrong validity check for
switch decoders, nr_targets is a topology limitation, not a
interleave_ways limitation. As far as I can see nothing breaks if a
decoder claims to support a target count that is not a valid
interleave_ways number.
So it was useful to go through this to get that clarified, but the
takeaway from 1/ is "there is insufficient risk" and the takeaway from
2/ is "nothing breaks even if switch decoder target count is 'invalid'".
The valid interleave_ways is a separate region-only property.
next prev parent reply other threads:[~2025-08-14 0:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 21:42 [PATCH] cxl/port: Validate decoder nr_targets against supported ways alison.schofield
2025-08-14 0:57 ` dan.j.williams [this message]
2025-08-14 3:12 ` Alison Schofield
2025-08-14 17:36 ` dan.j.williams
2025-08-21 0:37 ` Alison Schofield
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=689d348e41a66_2709100cb@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=vishal.l.verma@intel.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