cxl: Test CXL_DECODER_F_LOCK as a bitmask
Alison Schofield
maintainerPATCH v2 1/2 cxl: Test CXL_DECODER_F_LOCK as a bitmask
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_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.
---
Changes in v2:
Split patches to align w Fixes Tags for backport ease Rebased on 7.0-rc1
drivers/cxl/core/hdm.c | 2 +- drivers/cxl/core/region.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/cxl/core/hdm.c +1 -1
@@ -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)
drivers/cxl/core/region.c +1 -1
@@ -1100,7 +1100,7 @@ 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); }
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
Signature · 1 line
2.37.3
Alison Schofield
maintainerPATCH v2 2/2 cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask
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.
Replace test_bit() with a bitmask check.
Found with cxl-test.
---
Changes in v2:
Split patches to align w Fixes Tags for backport ease Rebased on 7.0-rc1
drivers/cxl/core/region.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/region.c +1 -1
@@ -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); }
Signature · 1 line
2.37.3
Re: [PATCH v2 2/2] cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask
Quoted 8 lines · Alison Schofield
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_ADDRESSINGthe test reads beyond the flags word, making the flag sometimes appear set and blocking creation of CXL region debugfs attributes that support poison operations.
Quoted 6 lines
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 <[email protected]>
Re: [PATCH v2 2/2] cxl/region: Test CXL_DECODER_F_NORMALIZED_ADDRESSING as a bitmask
In reply to Alison SchofieldQuoted 8 lines · Alison Schofield
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_ADDRESSINGthe test reads beyond the flags word, making the flag sometimes appear set and blocking creation of CXL region debugfs attributes that support poison operations.
Quoted 6 lines
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 <[email protected]>
Applied to cxl/fixesebd11be59f7421e4b1ea19eaa8102d17ade3d6c6
Quoted 22 lines
---
Changes in v2:
Split patches to align w Fixes Tags for backport ease Rebased on 7.0-rc1drivers/cxl/core/region.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/core/region.c +1
-1@@ -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); }
Quoted 8 lines · Alison Schofield
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_LOCKthe test reads beyond the defined bits, causing the test to always return false and allowing resets that should have been blocked.
Quoted 5 lines
Replace
test_bit()with a bitmask check.Fixes 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")Signed-off-by Alison Schofield <[email protected]>---
Op, missed the v4 and responded to v1
Quoted 4 lines · Alison Schofield
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.
Quoted 8 lines
For
CXL_DECODER_F_LOCKthe 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.Fixes 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")Signed-off-by Alison Schofield <[email protected]>
Applied to cxl/fixes8c0025ee29f03d74d34b77127192b9db8457564c
Quoted 38 lines
---
Changes in v2:
Split patches to align w Fixes Tags for backport ease Rebased on 7.0-rc1drivers/cxl/core/hdm.c | 2 +- drivers/cxl/core/region.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/cxl/core/hdm.c +1
-1@@ -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)drivers/cxl/core/region.c +1
-1@@ -1100,7 +1100,7 @@ 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); }base-commit:
6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f