From 14773723b75fc46c72c777c33e58901de7437c4f Mon Sep 17 00:00:00 2001 From: Alexey Romko Date: Thu, 9 Apr 2020 15:32:08 +0400 Subject: [PATCH] Add support for ROMD regions for hax Signed-off-by: Alexey Romko --- target/i386/hax-mem.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/target/i386/hax-mem.c b/target/i386/hax-mem.c index 6bb5a24917..16787fddcb 100644 --- a/target/i386/hax-mem.c +++ b/target/i386/hax-mem.c @@ -144,10 +144,17 @@ static void hax_update_mapping(uint64_t start_pa, uint32_t size, hax_insert_mapping_before(entry, start_pa, chunk_sz, host_va, flags); } - } else { /* affects the full mapping entry */ - if (nop) { /* no change to this mapping, remove it */ - QTAILQ_REMOVE(&mappings, entry, entry); - g_free(entry); + } else { + /* affects the full mapping entry */ + if (nop) { + /* no change to this mapping size, remove it if */ + /* current updating removed it */ + if( flags & HAX_RAM_INFO_INVALID ) { + QTAILQ_REMOVE(&mappings, entry, entry); + g_free(entry); + } else { + entry->flags = flags; + } } else { /* update mapping properties */ entry->host_va = host_va; entry->flags = flags; @@ -175,15 +182,16 @@ static void hax_process_section(MemoryRegionSection *section, uint8_t flags) uint64_t host_va; uint32_t max_mapping_size; - /* We only care about RAM and ROM regions */ - if (!memory_region_is_ram(mr)) { - if (memory_region_is_romd(mr)) { - /* HAXM kernel module does not support ROMD yet */ - warn_report("Ignoring ROMD region 0x%016" PRIx64 "->0x%016" PRIx64, - start_pa, start_pa + size); - } - return; + /* We care about additions of RAM, ROM and ROMD regions */ + if( mr->rom_device ) + { + /* Allow deleting romd regions in non-romd mode, don't add romd + regions in IO mode */ + if( !mr->romd_mode && ( flags != HAX_RAM_INFO_INVALID ) ) + return; } + else if( !memory_region_is_ram(mr) ) + return; /* Adjust start_pa and size so that they are page-aligned. (Cf * kvm_set_phys_mem() in kvm-all.c). @@ -202,7 +210,7 @@ static void hax_process_section(MemoryRegionSection *section, uint8_t flags) host_va = (uintptr_t)memory_region_get_ram_ptr(mr) + section->offset_within_region + delta; - if (memory_region_is_rom(section->mr)) { + if (memory_region_is_rom(section->mr) || memory_region_is_romd(section->mr)) { flags |= HAX_RAM_INFO_ROM; } -- 2.15.0.windows.1