* [PATCH] cxl: Test decoder flags as bitmasks
@ 2026-02-06 18:14 Alison Schofield
2026-02-06 19:33 ` Dave Jiang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Alison Schofield @ 2026-02-06 18:14 UTC (permalink / raw)
To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Ira Weiny, Dan Williams
Cc: linux-cxl
The CXL decoder flags are defined as bitmasks, not bit indices.
Using test_bit() to check them interprets the mask value as a bit
index, which is the wrong test.
For CXL_DECODER_F_NORMALIZED_ADDRESSING the test reads beyond the
flags word, making the flag sometimes appear set and blocking creation
of CXL region debugfs attributes that support poison operations.
For CXL_DECODER_F_LOCK the test reads beyond the defined bits, causing
the test to always return false and allowing resets that should have
been blocked.
Replace test_bit() with a bitmask check.
Found with cxl-test.
Fixes: 208f432406b7 ("cxl: Disable HPA/SPA translation handlers for Normalized Addressing")
Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
Obsoletes prior patch that only fixed up one test:
cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask
https://lore.kernel.org/linux-cxl/20260206013135.1012375-1-alison.schofield@intel.com/
drivers/cxl/core/hdm.c | 2 +-
drivers/cxl/core/region.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index e3f0c39e6812..c222e98ae736 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -904,7 +904,7 @@ static void cxl_decoder_reset(struct cxl_decoder *cxld)
if ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)
return;
- if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags))
+ if (cxld->flags & CXL_DECODER_F_LOCK)
return;
if (port->commit_end == id)
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 08fa3deef70a..befa2a7b81c2 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1100,12 +1100,12 @@ static int cxl_rr_assign_decoder(struct cxl_port *port, struct cxl_region *cxlr,
static void cxl_region_setup_flags(struct cxl_region *cxlr,
struct cxl_decoder *cxld)
{
- if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags)) {
+ if (cxld->flags & CXL_DECODER_F_LOCK) {
set_bit(CXL_REGION_F_LOCK, &cxlr->flags);
clear_bit(CXL_REGION_F_NEEDS_RESET, &cxlr->flags);
}
- if (test_bit(CXL_DECODER_F_NORMALIZED_ADDRESSING, &cxld->flags))
+ if (cxld->flags & CXL_DECODER_F_NORMALIZED_ADDRESSING)
set_bit(CXL_REGION_F_NORMALIZED_ADDRESSING, &cxlr->flags);
}
base-commit: 9845cf73f7db6094c0d8419d6adb848028f4a921
--
2.37.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] cxl: Test decoder flags as bitmasks
2026-02-06 18:14 [PATCH] cxl: Test decoder flags as bitmasks Alison Schofield
@ 2026-02-06 19:33 ` Dave Jiang
2026-02-09 16:28 ` Alison Schofield
2026-02-17 22:25 ` Davidlohr Bueso
2026-02-23 20:09 ` Gregory Price
2 siblings, 1 reply; 5+ messages in thread
From: Dave Jiang @ 2026-02-06 19:33 UTC (permalink / raw)
To: Alison Schofield, Davidlohr Bueso, Jonathan Cameron, Vishal Verma,
Ira Weiny, Dan Williams
Cc: linux-cxl
On 2/6/26 11:14 AM, Alison Schofield wrote:
> The CXL decoder flags are defined as bitmasks, not bit indices.
> Using test_bit() to check them interprets the mask value as a bit
> index, which is the wrong test.
>
> For CXL_DECODER_F_NORMALIZED_ADDRESSING the test reads beyond the
> flags word, making the flag sometimes appear set and blocking creation
> of CXL region debugfs attributes that support poison operations.
>
> For CXL_DECODER_F_LOCK the test reads beyond the defined bits, causing
> the test to always return false and allowing resets that should have
> been blocked.
>
> Replace test_bit() with a bitmask check.
>
> Found with cxl-test.
>
> Fixes: 208f432406b7 ("cxl: Disable HPA/SPA translation handlers for Normalized Addressing")
> Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
Given it needs to back port and fix 2 different commits, maybe this needs to split?
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
>
> Obsoletes prior patch that only fixed up one test:
> cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask
> https://lore.kernel.org/linux-cxl/20260206013135.1012375-1-alison.schofield@intel.com/
>
>
> drivers/cxl/core/hdm.c | 2 +-
> drivers/cxl/core/region.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index e3f0c39e6812..c222e98ae736 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -904,7 +904,7 @@ static void cxl_decoder_reset(struct cxl_decoder *cxld)
> if ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)
> return;
>
> - if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags))
> + if (cxld->flags & CXL_DECODER_F_LOCK)
> return;
>
> if (port->commit_end == id)
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 08fa3deef70a..befa2a7b81c2 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1100,12 +1100,12 @@ static int cxl_rr_assign_decoder(struct cxl_port *port, struct cxl_region *cxlr,
> static void cxl_region_setup_flags(struct cxl_region *cxlr,
> struct cxl_decoder *cxld)
> {
> - if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags)) {
> + if (cxld->flags & CXL_DECODER_F_LOCK) {
> set_bit(CXL_REGION_F_LOCK, &cxlr->flags);
> clear_bit(CXL_REGION_F_NEEDS_RESET, &cxlr->flags);
> }
>
> - if (test_bit(CXL_DECODER_F_NORMALIZED_ADDRESSING, &cxld->flags))
> + if (cxld->flags & CXL_DECODER_F_NORMALIZED_ADDRESSING)
> set_bit(CXL_REGION_F_NORMALIZED_ADDRESSING, &cxlr->flags);
> }
>
>
> base-commit: 9845cf73f7db6094c0d8419d6adb848028f4a921
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] cxl: Test decoder flags as bitmasks
2026-02-06 19:33 ` Dave Jiang
@ 2026-02-09 16:28 ` Alison Schofield
0 siblings, 0 replies; 5+ messages in thread
From: Alison Schofield @ 2026-02-09 16:28 UTC (permalink / raw)
To: Dave Jiang
Cc: Davidlohr Bueso, Jonathan Cameron, Vishal Verma, Ira Weiny,
Dan Williams, linux-cxl
On Fri, Feb 06, 2026 at 12:33:34PM -0700, Dave Jiang wrote:
>
>
> On 2/6/26 11:14 AM, Alison Schofield wrote:
> > The CXL decoder flags are defined as bitmasks, not bit indices.
> > Using test_bit() to check them interprets the mask value as a bit
> > index, which is the wrong test.
> >
> > For CXL_DECODER_F_NORMALIZED_ADDRESSING the test reads beyond the
> > flags word, making the flag sometimes appear set and blocking creation
> > of CXL region debugfs attributes that support poison operations.
> >
> > For CXL_DECODER_F_LOCK the test reads beyond the defined bits, causing
> > the test to always return false and allowing resets that should have
> > been blocked.
> >
> > Replace test_bit() with a bitmask check.
> >
> > Found with cxl-test.
> >
> > Fixes: 208f432406b7 ("cxl: Disable HPA/SPA translation handlers for Normalized Addressing")
> > Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
>
> Given it needs to back port and fix 2 different commits, maybe this needs to split?
OK - will do, ignore this patch.
It'll be a 2 patch series because of the dependency, but I believe that
is still preferred by backport folks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl: Test decoder flags as bitmasks
2026-02-06 18:14 [PATCH] cxl: Test decoder flags as bitmasks Alison Schofield
2026-02-06 19:33 ` Dave Jiang
@ 2026-02-17 22:25 ` Davidlohr Bueso
2026-02-23 20:09 ` Gregory Price
2 siblings, 0 replies; 5+ messages in thread
From: Davidlohr Bueso @ 2026-02-17 22:25 UTC (permalink / raw)
To: Alison Schofield
Cc: Jonathan Cameron, Dave Jiang, Vishal Verma, Ira Weiny,
Dan Williams, linux-cxl
On Fri, 06 Feb 2026, Alison Schofield wrote:
>The CXL decoder flags are defined as bitmasks, not bit indices.
>Using test_bit() to check them interprets the mask value as a bit
>index, which is the wrong test.
>
>For CXL_DECODER_F_NORMALIZED_ADDRESSING the test reads beyond the
>flags word, making the flag sometimes appear set and blocking creation
>of CXL region debugfs attributes that support poison operations.
>
>For CXL_DECODER_F_LOCK the test reads beyond the defined bits, causing
>the test to always return false and allowing resets that should have
>been blocked.
>
>Replace test_bit() with a bitmask check.
>
>Found with cxl-test.
>
Nice find. Other than splitting the fixes as suggested by Dave:
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl: Test decoder flags as bitmasks
2026-02-06 18:14 [PATCH] cxl: Test decoder flags as bitmasks Alison Schofield
2026-02-06 19:33 ` Dave Jiang
2026-02-17 22:25 ` Davidlohr Bueso
@ 2026-02-23 20:09 ` Gregory Price
2 siblings, 0 replies; 5+ messages in thread
From: Gregory Price @ 2026-02-23 20:09 UTC (permalink / raw)
To: Alison Schofield
Cc: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Vishal Verma,
Ira Weiny, Dan Williams, linux-cxl
On Fri, Feb 06, 2026 at 10:14:02AM -0800, Alison Schofield wrote:
> The CXL decoder flags are defined as bitmasks, not bit indices.
> Using test_bit() to check them interprets the mask value as a bit
> index, which is the wrong test.
>
> For CXL_DECODER_F_NORMALIZED_ADDRESSING the test reads beyond the
> flags word, making the flag sometimes appear set and blocking creation
> of CXL region debugfs attributes that support poison operations.
>
> For CXL_DECODER_F_LOCK the test reads beyond the defined bits, causing
> the test to always return false and allowing resets that should have
> been blocked.
>
> Replace test_bit() with a bitmask check.
>
> Found with cxl-test.
>
> Fixes: 208f432406b7 ("cxl: Disable HPA/SPA translation handlers for Normalized Addressing")
> Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
I independently found and fixed this with the same patch. So +1
Reviewed-by: Gregory Price <gourry@gourry.net>
Tested-by: Gregory Price <gourry@gourry.net>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-23 20:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-06 18:14 [PATCH] cxl: Test decoder flags as bitmasks Alison Schofield
2026-02-06 19:33 ` Dave Jiang
2026-02-09 16:28 ` Alison Schofield
2026-02-17 22:25 ` Davidlohr Bueso
2026-02-23 20:09 ` Gregory Price
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox