qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Avoid cpu_physical_memory_rw() with a constant is_write argument

This commit was produced with the included Coccinelle script
scripts/coccinelle/exec_rw_const.

Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

+15 -3
+1 -1
hw/xen/xen_pt_graphics.c
··· 222 222 } 223 223 224 224 /* Currently we fixed this address as a primary for legacy BIOS. */ 225 - cpu_physical_memory_rw(0xc0000, bios, bios_size, true); 225 + cpu_physical_memory_write(0xc0000, bios, bios_size); 226 226 } 227 227 228 228 uint32_t igd_read_opregion(XenPCIPassthroughState *s)
+12
scripts/coccinelle/exec_rw_const.cocci
··· 62 62 + address_space_write(E1, E2, E3, E4, E5) 63 63 ) 64 64 65 + // Avoid uses of cpu_physical_memory_rw() with a constant is_write argument. 66 + @@ 67 + expression E1, E2, E3; 68 + @@ 69 + ( 70 + - cpu_physical_memory_rw(E1, E2, E3, false) 71 + + cpu_physical_memory_read(E1, E2, E3) 72 + | 73 + - cpu_physical_memory_rw(E1, E2, E3, true) 74 + + cpu_physical_memory_write(E1, E2, E3) 75 + ) 76 + 65 77 // Remove useless cast 66 78 @@ 67 79 expression E1, E2, E3, E4, E5, E6;
+2 -2
target/i386/hax-all.c
··· 376 376 * hft->direction == 2: gpa ==> gpa2 377 377 */ 378 378 uint64_t value; 379 - cpu_physical_memory_rw(hft->gpa, &value, hft->size, false); 380 - cpu_physical_memory_rw(hft->gpa2, &value, hft->size, true); 379 + cpu_physical_memory_read(hft->gpa, &value, hft->size); 380 + cpu_physical_memory_write(hft->gpa2, &value, hft->size); 381 381 } 382 382 383 383 return 0;