cxl/acpi: Fix using extra xormaps for address translation
Li Ming
reviewerPATCH 1/1 cxl/acpi: Fix using extra xormaps for address translation
CXL r3.1 Table 9-22 defines a fixed number of XOR maps for interleave arithmetic based on the number of interleave ways, as reflected by hbiw_to_nr_maps[].
The current implementation applies all XOR maps during address translation, but it should use the spec-defined number of XOR maps derived from the number of interleave ways.
--- drivers/cxl/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/acpi.c +1 -1
@@ -61,7 +61,7 @@ u64 cxl_do_xormap_calc(struct cxl_cxims_data *cximsd, u64 addr, int hbiw)* bits results in val==0, if odd the XOR result is val==1. */ -for (int i =0 ; i < cximsd->nr_maps; i++) { +for (int i =0 ; i < nr_maps_to_apply; i++) {if (!cximsd->xormaps[i])continue ; pos =__ffs (cximsd->xormaps[i]);
Signature · 1 line
2.34.1
Dave Jiang
maintainerQuoted 7 lines · Li Ming
CXL r3.1 Table 9-22 defines a fixed number of XOR maps for interleave arithmetic based on the number of interleave ways, as reflected by hbiw_to_nr_maps[].
The current implementation applies all XOR maps during address translation, but it should use the spec-defined number of XOR maps derived from the number of interleave ways.
Can you add what is the current impact without applying the fix pls?
DJ
Quoted 20 lines
Fixes 3b2fedcd75e3 ("cxl: Restore XOR'd position bits during address translation")Signed-off-by Li Ming <[email protected]>--- drivers/cxl/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/acpi.c +1
-1@@ -61,7 +61,7 @@ u64 cxl_do_xormap_calc(struct cxl_cxims_data *cximsd, u64 addr, int hbiw)* bits results in val==0, if odd the XOR result is val==1. */ -for (int i =0 ; i < cximsd->nr_maps; i++) { +for (int i =0 ; i < nr_maps_to_apply; i++) {if (!cximsd->xormaps[i])continue ; pos =__ffs (cximsd->xormaps[i]);
Alison Schofield
maintainerQuoted 10 lines · Li Ming
CXL r3.1 Table 9-22 defines a fixed number of XOR maps for interleave arithmetic based on the number of interleave ways, as reflected by hbiw_to_nr_maps[].
The current implementation applies all XOR maps during address translation, but it should use the spec-defined number of XOR maps derived from the number of interleave ways.
Fixes 3b2fedcd75e3 ("cxl: Restore XOR'd position bits during address translation")Signed-off-by Li Ming <[email protected]>
Ming,
I previously sent similar patch and then recalled it for the reason described in this thread.
https://lore.kernel.org/linux-cxl/[email protected]
The above was all before
"4fe516d2ad1a6 cxl/acpi: Make the XOR calculations available for testing"
where I added input param checking and introduced nr_maps_to_apply.
I don't think it is necessary to use nr_maps_to_apply in the for loop once the params have been validated. So maybe this patch is a cleanup on commit 4fe516d2ad1a6 rather than a fix.
Please take a look again and let me know if I'm wrong again ;)
--Alison
Quoted 20 lines
--- drivers/cxl/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/acpi.c +1
-1@@ -61,7 +61,7 @@ u64 cxl_do_xormap_calc(struct cxl_cxims_data *cximsd, u64 addr, int hbiw)* bits results in val==0, if odd the XOR result is val==1. */ -for (int i =0 ; i < cximsd->nr_maps; i++) { +for (int i =0 ; i < nr_maps_to_apply; i++) {if (!cximsd->xormaps[i])continue ; pos =__ffs (cximsd->xormaps[i]);Signature · 1 line
2.34.1
Li Ming
reviewerQuoted 21 lines · Alison Schofield
Quoted 10 lines · Li Ming
CXL r3.1 Table 9-22 defines a fixed number of XOR maps for interleave arithmetic based on the number of interleave ways, as reflected by hbiw_to_nr_maps[].
The current implementation applies all XOR maps during address translation, but it should use the spec-defined number of XOR maps derived from the number of interleave ways.
Fixes 3b2fedcd75e3 ("cxl: Restore XOR'd position bits during address translation")Signed-off-by Li Ming <[email protected]>Ming,
I previously sent similar patch and then recalled it for the reason described in this thread.
https://lore.kernel.org/linux-cxl/[email protected]The above was all before
"4fe516d2ad1a6cxl/acpi: Make the XOR calculations available for testing"
where I added input param checking and introducednr_maps_to_apply.
Quoted 7 lines
I don't think it is necessary to use
nr_maps_to_applyin the for loop once the params have been validated. So maybe this patch is a cleanup on commit4fe516d2ad1a6rather than a fix.Please take a look again and let me know if I'm wrong again ;)
--Alison
Hi Alison,
Thanks for pointing it out, you are right, it is not a bug. After reviewing cxl_parse_cxims(), the cxmisd->xormaps stores the correct number of xor maps based on the interleave ways. In fact, nr_maps_to_apply is equal to cximsd->nr_maps in cxl_do_xormap_calc(), So it is not needed to change it.
Hi Alison and Dave,
Please ignore this patch, apologies for the noise.
Thanks
Ming
Quoted 21 lines
Quoted 21 lines
--- drivers/cxl/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/acpi.c +1
-1@@ -61,7 +61,7 @@ u64 cxl_do_xormap_calc(struct cxl_cxims_data *cximsd, u64 addr, int hbiw)* bits results in val==0, if odd the XOR result is val==1. */ -for (int i =0 ; i < cximsd->nr_maps; i++) { +for (int i =0 ; i < nr_maps_to_apply; i++) {if (!cximsd->xormaps[i])continue ; pos =__ffs (cximsd->xormaps[i]);Signature · 1 line
2.34.1