From: Ian Campbell Date: Tue, 2 Feb 2016 15:44:09 +0000 (+0000) Subject: xen: use xendevicemodel_make_ram_region_{ro,rw} X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;ds=sidebyside;p=people%2Fliuw%2Flibxenctrl-split%2Fqemu-xen.git xen: use xendevicemodel_make_ram_region_{ro,rw} Rather than expose the xen_dm handle outside of xen-hvm.c introduce a function wrapper for xen_platform to use. Signed-off-by: Ian Campbell --- diff --git a/configure b/configure index b5d9219df..783c49870 100755 --- a/configure +++ b/configure @@ -2185,6 +2185,7 @@ int main(void) { xendevicemodel_populate_ram(dm, 0, 0); xendevicemodel_create_ioreq_server(dm, 1, NULL); xendevicemodel_mark_memory_region_dirty(dm, 0, 0); + xendevicemodel_make_ram_region_ro(dm, 0, 0); return 0; } EOF diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c index a2247b917..154596ff0 100644 --- a/hw/i386/xen/xen_platform.c +++ b/hw/i386/xen/xen_platform.c @@ -179,14 +179,12 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v switch (addr) { case 0: /* Platform flags */ { - hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ? - HVMMEM_ram_ro : HVMMEM_ram_rw; - if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, 0xc0, 0x40)) { + if (xen_hvm_set_rom_ro(val & PFFLAG_ROM_LOCK)) { DPRINTF("unable to change ro/rw state of ROM memory area!\n"); } else { s->flags = val & PFFLAG_ROM_LOCK; DPRINTF("changed ro/rw state of ROM memory area. now is %s state.\n", - (mem_type == HVMMEM_ram_ro ? "ro":"rw")); + (val & PFFLAG_ROM_LOCK ? "ro":"rw")); } break; } diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index df334818c..5bf47645c 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -34,6 +34,7 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int level); void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len); void xen_hvm_inject_msi(uint64_t addr, uint32_t data); int xen_is_pirq_msi(uint32_t msi_data); +int xen_hvm_set_rom_ro(int ro); qemu_irq *xen_interrupt_controller_init(void); diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 58c479e38..565581d64 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -154,6 +154,10 @@ static inline int xendevicemodel_populate_ram(xendevicemodel_handle *h, #define xendevicemodel_mark_memory_region_dirty(h, s, n) \ xc_hvm_modified_memory(h, xen_domid, s, n) +#define xendevicemodel_make_ram_region_ro(h, s, n) \ + xc_hvm_set_mem_type(h, xen_domid, HVMMEM_ram_ro, s, n) +#define xendevicemodel_make_ram_region_rw(h, s, n) \ + xc_hvm_set_mem_type(h, xen_domid, HVMMEM_ram_rw, s, n) #if CONFIG_XEN_CTRL_INTERFACE_VERSION >= 450 diff --git a/xen-hvm.c b/xen-hvm.c index a6807a0a1..7220933c2 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -162,6 +162,14 @@ void xen_hvm_inject_msi(uint64_t addr, uint32_t data) xendevicemodel_inject_msi(xen_dm, addr, data); } +int xen_hvm_set_rom_ro(int ro) +{ + if (ro) + return xendevicemodel_make_ram_region_ro(xen_dm, 0xc0, 0x40); + else + return xendevicemodel_make_ram_region_rw(xen_dm, 0xc0, 0x40); +} + static void xen_suspend_notifier(Notifier *n, void *data) { xendevicemodel_s3_suspend(xen_dm); @@ -437,7 +445,6 @@ static void xen_set_memory(struct MemoryListener *listener, hwaddr start_addr = section->offset_within_address_space; ram_addr_t size = int128_get64(section->size); bool log_dirty = memory_region_is_logging(section->mr, DIRTY_MEMORY_VGA); - hvmmem_type_t mem_type; if (section->mr == &ram_memory) { return; @@ -467,11 +474,10 @@ static void xen_set_memory(struct MemoryListener *listener, xen_add_to_physmap(state, start_addr, size, section->mr, section->offset_within_region); } else { - mem_type = HVMMEM_ram_ro; - if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, + if (xendevicemodel_make_ram_region_ro(xen_dm, start_addr >> TARGET_PAGE_BITS, size >> TARGET_PAGE_BITS)) { - DPRINTF("xc_hvm_set_mem_type error, addr: "TARGET_FMT_plx"\n", + DPRINTF("make_ram_region_ro error, addr: "TARGET_FMT_plx"\n", start_addr); } }