Skip to contentSkip to conversation

powerpc/ps3: Fix map failure path in dma_ioc0_map_pages()

PATCH Applied Thorsten Blum 5 participants 6 messages Jul 11 – Jul 30

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 6bb5cf102541 ("[POWERPC] PS3: System-bus rework")
---
 arch/powerpc/platforms/ps3/mm.c | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/platforms/ps3/mm.c +1 -0
index 20fc5b68faee..315a32fd75b1 100644
@@ -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,
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Thorsten Blum

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.

Fixes 6bb5cf102541 ("[POWERPC] PS3: System-bus rework")

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
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Thorsten Blum
Quoted 7 lines · Thorsten Blum

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.

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
---
 arch/powerpc/platforms/ps3/mm.c | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/platforms/ps3/mm.c +1 -0
index 20fc5b68faee..315a32fd75b1 100644
@@ -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,
#3 lore raw
Quoted 7 lines · Ritesh Harjani
Quoted 5 lines · Thorsten Blum

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.

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:

Thanks,
Thorsten

#4 lore raw
Quoted 15 lines · Thorsten Blum
Quoted 7 lines · Ritesh Harjani
Quoted 5 lines · Thorsten Blum

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.

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:

Thanks,
Thorsten

Regards,
Florian

maintainer Applied
#5 lore raw
In reply to Thorsten Blum
Quoted 8 lines · Thorsten Blum

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.

[...]

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