diff options
author | Philippe Mathieu-Daudé <philmd@redhat.com> | 2020-02-19 20:34:58 +0100 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@redhat.com> | 2020-02-20 14:47:08 +0100 |
commit | adeefe01671fb06a930beba624dc3db8367901a3 (patch) | |
tree | f44912b5d7fec71b783a96fbcd8f1b2c95efed11 | |
parent | 85eb7c18ee39e26002de6fa6abc5638af140e588 (diff) | |
download | qemu-adeefe01671fb06a930beba624dc3db8367901a3.zip qemu-adeefe01671fb06a930beba624dc3db8367901a3.tar.gz qemu-adeefe01671fb06a930beba624dc3db8367901a3.tar.bz2 |
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>
-rw-r--r-- | hw/xen/xen_pt_graphics.c | 2 | ||||
-rw-r--r-- | scripts/coccinelle/exec_rw_const.cocci | 12 | ||||
-rw-r--r-- | target/i386/hax-all.c | 4 |
3 files changed, 15 insertions, 3 deletions
diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index b11e4e0..a3bc7e3 100644 --- a/hw/xen/xen_pt_graphics.c +++ b/hw/xen/xen_pt_graphics.c @@ -222,7 +222,7 @@ void xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev, } /* Currently we fixed this address as a primary for legacy BIOS. */ - cpu_physical_memory_rw(0xc0000, bios, bios_size, true); + cpu_physical_memory_write(0xc0000, bios, bios_size); } uint32_t igd_read_opregion(XenPCIPassthroughState *s) diff --git a/scripts/coccinelle/exec_rw_const.cocci b/scripts/coccinelle/exec_rw_const.cocci index 35ab79e..1a20296 100644 --- a/scripts/coccinelle/exec_rw_const.cocci +++ b/scripts/coccinelle/exec_rw_const.cocci @@ -62,6 +62,18 @@ symbol true, false; + address_space_write(E1, E2, E3, E4, E5) ) +// Avoid uses of cpu_physical_memory_rw() with a constant is_write argument. +@@ +expression E1, E2, E3; +@@ +( +- cpu_physical_memory_rw(E1, E2, E3, false) ++ cpu_physical_memory_read(E1, E2, E3) +| +- cpu_physical_memory_rw(E1, E2, E3, true) ++ cpu_physical_memory_write(E1, E2, E3) +) + // Remove useless cast @@ expression E1, E2, E3, E4, E5, E6; diff --git a/target/i386/hax-all.c b/target/i386/hax-all.c index 38936d7..f9c83ff 100644 --- a/target/i386/hax-all.c +++ b/target/i386/hax-all.c @@ -376,8 +376,8 @@ static int hax_handle_fastmmio(CPUArchState *env, struct hax_fastmmio *hft) * hft->direction == 2: gpa ==> gpa2 */ uint64_t value; - cpu_physical_memory_rw(hft->gpa, &value, hft->size, false); - cpu_physical_memory_rw(hft->gpa2, &value, hft->size, true); + cpu_physical_memory_read(hft->gpa, &value, hft->size); + cpu_physical_memory_write(hft->gpa2, &value, hft->size); } return 0; |