public inbox for linux-cxl@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask
@ 2026-02-06  1:31 Alison Schofield
  2026-02-06  1:46 ` Alison Schofield
  0 siblings, 1 reply; 2+ messages in thread
From: Alison Schofield @ 2026-02-06  1:31 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Dan Williams
  Cc: linux-cxl

CXL_DECODER_F_NORMALIZED_ADDRESSING is a bitmask, not a bit index.
Using test_bit() to check it caused undefined behavior making the
flag sometimes appear set. This prevented creation of CXL region
debugfs attributes that support poison actions.

Replace test_bit() with a bitmask check.

Found with cxl-test.

Fixes: 208f432406b7 ("cxl: Disable HPA/SPA translation handlers for Normalized Addressing")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---

DaveJ: The base commit tag is linux-next today. I figure it's closest to what
we'll see w 7.0-rc1. 


 drivers/cxl/core/region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 08fa3deef70a..00a9b57cdd80 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1105,7 +1105,7 @@ static void cxl_region_setup_flags(struct cxl_region *cxlr,
 		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] 2+ messages in thread

* Re: [PATCH] cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask
  2026-02-06  1:31 [PATCH] cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask Alison Schofield
@ 2026-02-06  1:46 ` Alison Schofield
  0 siblings, 0 replies; 2+ messages in thread
From: Alison Schofield @ 2026-02-06  1:46 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Vishal Verma,
	Ira Weiny, Dan Williams
  Cc: linux-cxl

On Thu, Feb 05, 2026 at 05:31:33PM -0800, Alison Schofield wrote:
> CXL_DECODER_F_NORMALIZED_ADDRESSING is a bitmask, not a bit index.
> Using test_bit() to check it caused undefined behavior making the
> flag sometimes appear set. This prevented creation of CXL region
> debugfs attributes that support poison actions.
> 
> Replace test_bit() with a bitmask check.
> 
> Found with cxl-test.

I was focused on getting this test case to work so it wasn't
until I hit send on the patch that I see there are a couple of
other places to stop using test_bit().
I'll respin and clean these up too:

hdm.c:		if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags))
region.c:	if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags)) {

> 
> Fixes: 208f432406b7 ("cxl: Disable HPA/SPA translation handlers for Normalized Addressing")
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
> 
> DaveJ: The base commit tag is linux-next today. I figure it's closest to what
> we'll see w 7.0-rc1. 
> 
> 
>  drivers/cxl/core/region.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 08fa3deef70a..00a9b57cdd80 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1105,7 +1105,7 @@ static void cxl_region_setup_flags(struct cxl_region *cxlr,
>  		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	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-06  1:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-06  1:31 [PATCH] cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask Alison Schofield
2026-02-06  1:46 ` Alison Schofield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox