[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 098/136] Avoid cpu_physical_memory_rw() with a constant is_write a
From: |
Paolo Bonzini |
Subject: |
[PULL 098/136] Avoid cpu_physical_memory_rw() with a constant is_write argument |
Date: |
Tue, 25 Feb 2020 12:50:28 +0100 |
From: Philippe Mathieu-Daudé <address@hidden>
This commit was produced with the included Coccinelle script
scripts/coccinelle/exec_rw_const.
Inspired-by: Peter Maydell <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/xen/xen_pt_graphics.c | 2 +-
scripts/coccinelle/exec_rw_const.cocci | 12 ++++++++++++
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;
--
1.8.3.1
- [PULL 086/136] Remove unnecessary cast when using the address_space API, (continued)
- [PULL 086/136] Remove unnecessary cast when using the address_space API, Paolo Bonzini, 2020/02/25
- [PULL 088/136] Remove unnecessary cast when using the cpu_[physical]_memory API, Paolo Bonzini, 2020/02/25
- [PULL 090/136] hw/ide: Let the DMAIntFunc prototype use a boolean 'is_write' argument, Paolo Bonzini, 2020/02/25
- [PULL 091/136] hw/virtio: Let virtqueue_map_iovec() use a boolean 'is_write' argument, Paolo Bonzini, 2020/02/25
- [PULL 092/136] hw/virtio: Let vhost_memory_map() use a boolean 'is_write' argument, Paolo Bonzini, 2020/02/25
- [PULL 093/136] exec: Let address_space_unmap() use a boolean 'is_write' argument, Paolo Bonzini, 2020/02/25
- [PULL 096/136] exec: Let cpu_[physical]_memory API use a boolean 'is_write' argument, Paolo Bonzini, 2020/02/25
- [PULL 094/136] Let address_space_rw() calls pass a boolean 'is_write' argument, Paolo Bonzini, 2020/02/25
- [PULL 099/136] memory: Correctly return alias region type, Paolo Bonzini, 2020/02/25
- [PULL 097/136] Let cpu_[physical]_memory() calls pass a boolean 'is_write' argument, Paolo Bonzini, 2020/02/25
- [PULL 098/136] Avoid cpu_physical_memory_rw() with a constant is_write argument,
Paolo Bonzini <=
- [PULL 095/136] Avoid address_space_rw() with a constant is_write argument, Paolo Bonzini, 2020/02/25
- [PULL 102/136] scripts/cocci: Patch to replace memory_region_init_{ram, readonly -> rom}, Paolo Bonzini, 2020/02/25
- [PULL 100/136] memory: Simplify memory_region_init_rom_nomigrate() to ease review, Paolo Bonzini, 2020/02/25
- [PULL 101/136] scripts/cocci: Rename memory-region-{init-ram -> housekeeping}, Paolo Bonzini, 2020/02/25
- [PULL 103/136] hw/arm: Use memory_region_init_rom() with read-only regions, Paolo Bonzini, 2020/02/25
- [PULL 104/136] hw/display: Use memory_region_init_rom() with read-only regions, Paolo Bonzini, 2020/02/25
- [PULL 103/136] hw/arm: Use memory_region_init_rom() with read-only regions, Paolo Bonzini, 2020/02/25
- [PULL 105/136] hw/mips: Use memory_region_init_rom() with read-only regions, Paolo Bonzini, 2020/02/25
- [PULL 106/136] hw/m68k: Use memory_region_init_rom() with read-only regions, Paolo Bonzini, 2020/02/25
- [PULL 107/136] hw/net: Use memory_region_init_rom() with read-only regions, Paolo Bonzini, 2020/02/25