cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

exec_rw_const.cocci (2553B)


      1/*
      2  Usage:
      3
      4    spatch \
      5           --macro-file scripts/cocci-macro-file.h \
      6           --sp-file scripts/coccinelle/exec_rw_const.cocci \
      7           --keep-comments \
      8           --in-place \
      9           --dir .
     10*/
     11
     12// Convert to boolean
     13@@
     14expression E1, E2, E3, E4, E5;
     15@@
     16(
     17- address_space_rw(E1, E2, E3, E4, E5, 0)
     18+ address_space_rw(E1, E2, E3, E4, E5, false)
     19|
     20- address_space_rw(E1, E2, E3, E4, E5, 1)
     21+ address_space_rw(E1, E2, E3, E4, E5, true)
     22|
     23
     24- cpu_physical_memory_rw(E1, E2, E3, 0)
     25+ cpu_physical_memory_rw(E1, E2, E3, false)
     26|
     27- cpu_physical_memory_rw(E1, E2, E3, 1)
     28+ cpu_physical_memory_rw(E1, E2, E3, true)
     29|
     30
     31- cpu_physical_memory_map(E1, E2, 0)
     32+ cpu_physical_memory_map(E1, E2, false)
     33|
     34- cpu_physical_memory_map(E1, E2, 1)
     35+ cpu_physical_memory_map(E1, E2, true)
     36)
     37
     38// Use address_space_write instead of casting to non-const
     39@@
     40type T;
     41const T *V;
     42expression E1, E2, E3, E4;
     43@@
     44(
     45- address_space_rw(E1, E2, E3, (T *)V, E4, 1)
     46+ address_space_write(E1, E2, E3, V, E4)
     47|
     48- address_space_rw(E1, E2, E3, (void *)V, E4, 1)
     49+ address_space_write(E1, E2, E3, V, E4)
     50)
     51
     52// Avoid uses of address_space_rw() with a constant is_write argument.
     53@@
     54expression E1, E2, E3, E4, E5;
     55symbol true, false;
     56@@
     57(
     58- address_space_rw(E1, E2, E3, E4, E5, false)
     59+ address_space_read(E1, E2, E3, E4, E5)
     60|
     61- address_space_rw(E1, E2, E3, E4, E5, true)
     62+ address_space_write(E1, E2, E3, E4, E5)
     63)
     64
     65// Avoid uses of cpu_physical_memory_rw() with a constant is_write argument.
     66@@
     67expression 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
     77// Remove useless cast
     78@@
     79expression E1, E2, E3, E4, E5, E6;
     80type T;
     81@@
     82(
     83- address_space_rw(E1, E2, E3, (T *)(E4), E5, E6)
     84+ address_space_rw(E1, E2, E3, E4, E5, E6)
     85|
     86- address_space_read(E1, E2, E3, (T *)(E4), E5)
     87+ address_space_read(E1, E2, E3, E4, E5)
     88|
     89- address_space_write(E1, E2, E3, (T *)(E4), E5)
     90+ address_space_write(E1, E2, E3, E4, E5)
     91|
     92- address_space_write_rom(E1, E2, E3, (T *)(E4), E5)
     93+ address_space_write_rom(E1, E2, E3, E4, E5)
     94|
     95
     96- cpu_physical_memory_rw(E1, (T *)(E2), E3, E4)
     97+ cpu_physical_memory_rw(E1, E2, E3, E4)
     98|
     99- cpu_physical_memory_read(E1, (T *)(E2), E3)
    100+ cpu_physical_memory_read(E1, E2, E3)
    101|
    102- cpu_physical_memory_write(E1, (T *)(E2), E3)
    103+ cpu_physical_memory_write(E1, E2, E3)
    104|
    105
    106- dma_memory_read(E1, E2, (T *)(E3), E4)
    107+ dma_memory_read(E1, E2, E3, E4)
    108|
    109- dma_memory_write(E1, E2, (T *)(E3), E4)
    110+ dma_memory_write(E1, E2, E3, E4)
    111)