Avoid address_space_rw() with a constant is_write argument
The address_space_rw() function allows either reads or writes depending on the is_write argument passed to it; this is useful when the direction of the access is determined programmatically (as for instance when handling the KVM_EXIT_MMIO exit reason). Under the hood it just calls either address_space_write() or address_space_read_full(). We also use it a lot with a constant is_write argument, though, which has two issues: * when reading "address_space_rw(..., 1)" this is less immediately clear to the reader as being a write than "address_space_write(...)" * calling address_space_rw() bypasses the optimization in address_space_read() that fast-paths reads of a fixed length This commit was produced with the included Coccinelle script scripts/coccinelle/exec_rw_const.cocci. Signed-off-by:Peter Maydell <peter.maydell@linaro.org> Reviewed-by:
Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by:
Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by:
Laurent Vivier <lvivier@redhat.com> Reviewed-by:
Cédric Le Goater <clg@kaod.org> Acked-by:
Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by:
Cornelia Huck <cohuck@redhat.com> Reviewed-by:
Alistair Francis <alistair.francis@wdc.com> Acked-by:
David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200218112457.22712-1-peter.maydell@linaro.org> [PMD: Update macvm_set_cr0() reported by Laurent Vivier] Signed-off-by:
Philippe Mathieu-Daudé <philmd@redhat.com>
Showing
- accel/kvm/kvm-all.c 3 additions, 3 deletionsaccel/kvm/kvm-all.c
- dma-helpers.c 2 additions, 2 deletionsdma-helpers.c
- exec.c 2 additions, 2 deletionsexec.c
- hw/dma/xlnx-zdma.c 4 additions, 7 deletionshw/dma/xlnx-zdma.c
- hw/net/dp8393x.c 37 additions, 33 deletionshw/net/dp8393x.c
- hw/net/i82596.c 10 additions, 12 deletionshw/net/i82596.c
- hw/net/lasi_i82596.c 3 additions, 2 deletionshw/net/lasi_i82596.c
- hw/ppc/pnv_lpc.c 4 additions, 4 deletionshw/ppc/pnv_lpc.c
- hw/s390x/css.c 6 additions, 6 deletionshw/s390x/css.c
- qtest.c 26 additions, 26 deletionsqtest.c
- scripts/coccinelle/exec_rw_const.cocci 13 additions, 0 deletionsscripts/coccinelle/exec_rw_const.cocci
- target/i386/hvf/vmx.h 3 additions, 4 deletionstarget/i386/hvf/vmx.h
- target/i386/hvf/x86_mmu.c 6 additions, 6 deletionstarget/i386/hvf/x86_mmu.c
Loading
Please register or sign in to comment