aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2020-02-24 19:55:35 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2020-03-17 15:18:48 +0100
commitbb2f4e8d77c4b39ffc04614e0bbd71b3b3c3b340 (patch)
tree85ce57a705e9a72bc074d408160174fb4f522af3 /scripts
parentcf949cbb7079d3856ba61ceab44880ac88f0d7eb (diff)
downloadqemu-bb2f4e8d77c4b39ffc04614e0bbd71b3b3c3b340.zip
qemu-bb2f4e8d77c4b39ffc04614e0bbd71b3b3c3b340.tar.gz
qemu-bb2f4e8d77c4b39ffc04614e0bbd71b3b3c3b340.tar.bz2
scripts/cocci: Patch to remove unnecessary memory_region_set_readonly()
Add a semantic patch to remove memory_region_set_readonly() calls on ROM memory regions. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/memory-region-housekeeping.cocci15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index 9cdde71..5e6b31d 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -48,6 +48,21 @@ p << possible_memory_region_init_rom.p;
cocci.print_main("potential use of memory_region_init_rom*() in ", p)
+// Do not call memory_region_set_readonly() on ROM alias
+@@
+expression ROM, E1, E2, E3, E4;
+expression ALIAS, E5, E6, E7, E8;
+@@
+(
+ memory_region_init_rom(ROM, E1, E2, E3, E4);
+|
+ memory_region_init_rom_nomigrate(ROM, E1, E2, E3, E4);
+)
+ ...
+ memory_region_init_alias(ALIAS, E5, E6, ROM, E7, E8);
+- memory_region_set_readonly(ALIAS, true);
+
+
// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
// code sequences with use of the new memory_region_init_ram function.
// Similarly for the _rom and _rom_device functions.