powerpc/ps3: Fix map failure path in dma_ioc0_map_pages()
Subsystems (3)
PATCH 1/1 powerpc/ps3: Fix map failure path in dma_ioc0_map_pages()
If lv1_put_iopte() fails in dma_ioc0_map_pages(), the error path decrements iopage but keeps using the failed mapping's offset. As a result, it repeatedly tries to invalidate the failed IOPTE slot and leaves the already installed IOPTEs valid.
Recompute offset and invalidate the installed IOPTEs instead.
--- arch/powerpc/platforms/ps3/mm.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/ps3/mm.c +1 -0
@@ -615,6 +615,7 @@ static int dma_ioc0_map_pages(struct ps3_dma_region *r, unsigned long phys_addr, fail_map:for (iopage--;0 <= iopage; iopage--) { + offset = (1 << r->page_size) * iopage; lv1_put_iopte(0, c->bus_addr + offset, c->lpar_addr + offset,
Quoted 10 lines · Thorsten Blum
If
lv1_put_iopte()fails indma_ioc0_map_pages(), the error path decrements iopage but keeps using the failed mapping's offset. As a result, it repeatedly tries to invalidate the failed IOPTE slot and leaves the already installed IOPTEs valid.Recompute offset and invalidate the installed IOPTEs instead.
Fixes 6bb5cf102541 ("[POWERPC] PS3: System-bus rework")Signed-off-by Thorsten Blum <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 7 lines · Thorsten Blum
If
lv1_put_iopte()fails indma_ioc0_map_pages(), the error path decrements iopage but keeps using the failed mapping's offset. As a result, it repeatedly tries to invalidate the failed IOPTE slot and leaves the already installed IOPTEs valid.Recompute offset and invalidate the installed IOPTEs instead.
Nice catch! I wonder how did you catch this?
Do you have ps3 console where you somehow ran into this ;) Or was it a manual inspection?
I wonder whether PS3 consoles are still being used?
Quoted 1 line
Fixes 6bb5cf102541 ("[POWERPC] PS3: System-bus rework")
Looks like this was from 2007.
However, the change looks good to me. So:
Quoted 18 lines
Signed-off-by Thorsten Blum <[email protected]>--- arch/powerpc/platforms/ps3/mm.c | 1 + 1 file changed, 1 insertion(+)arch/powerpc/platforms/ps3/mm.c +1
-0@@ -615,6 +615,7 @@ static int dma_ioc0_map_pages(struct ps3_dma_region *r, unsigned long phys_addr, fail_map:for (iopage--;0 <= iopage; iopage--) { + offset = (1 << r->page_size) * iopage; lv1_put_iopte(0, c->bus_addr + offset, c->lpar_addr + offset,
Quoted 7 lines · Ritesh Harjani
Quoted 5 lines · Thorsten Blum
If
lv1_put_iopte()fails indma_ioc0_map_pages(), the error path decrements iopage but keeps using the failed mapping's offset. As a result, it repeatedly tries to invalidate the failed IOPTE slot and leaves the already installed IOPTEs valid.
Quoted 6 lines
Quoted 2 lines
Recompute offset and invalidate the installed IOPTEs instead.
Nice catch! I wonder how did you catch this?
Do you have ps3 console where you somehow ran into this ;) Or was it a manual inspection?
I do have a PS3 somewhere, but I stumbled upon this while reading and trying to understand the code.
Quoted 1 line
I wonder whether PS3 consoles are still being used?
Not sure.
Quoted 6 lines
Quoted 1 line
Fixes 6bb5cf102541 ("[POWERPC] PS3: System-bus rework")Looks like this was from 2007.
However, the change looks good to me. So:
Reviewed-by Ritesh Harjani (IBM) <[email protected]>
Thanks,
Thorsten
Quoted 15 lines · Thorsten Blum
Quoted 7 lines · Ritesh Harjani
Quoted 5 lines · Thorsten Blum
If
lv1_put_iopte()fails indma_ioc0_map_pages(), the error path decrements iopage but keeps using the failed mapping's offset. As a result, it repeatedly tries to invalidate the failed IOPTE slot and leaves the already installed IOPTEs valid.Quoted 6 lines
Quoted 2 lines
Recompute offset and invalidate the installed IOPTEs instead.
Nice catch! I wonder how did you catch this?
Do you have ps3 console where you somehow ran into this ;) Or was it a manual inspection?
Quoted 7 lines
I do have a PS3 somewhere, but I stumbled upon this while reading and trying to understand the code.
Quoted 1 line
I wonder whether PS3 consoles are still being used?
Not sure.
Yes, indeed, they are :-) But I'm not sure on how to test or inject the error path, so I can't add anything useful to that. Beside, thanks for keeping an eye on the good stuff.
Quoted 10 lines
Quoted 6 lines
Quoted 1 line
Fixes 6bb5cf102541 ("[POWERPC] PS3: System-bus rework")Looks like this was from 2007.
However, the change looks good to me. So:
Reviewed-by Ritesh Harjani (IBM) <[email protected]>Thanks,
Thorsten
Regards,
Florian
Quoted 8 lines · Thorsten Blum
If
lv1_put_iopte()fails indma_ioc0_map_pages(), the error path decrements iopage but keeps using the failed mapping's offset. As a result, it repeatedly tries to invalidate the failed IOPTE slot and leaves the already installed IOPTEs valid.Recompute offset and invalidate the installed IOPTEs instead.
[...]
Applied to powerpc/fixes.
[1/1] powerpc/ps3: Fix map failure path in dma_ioc0_map_pages()
https://git.kernel.org/powerpc/c/0bb024f11d120abff3e8db9144a585b9d7fb8459
cheers