]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/qemu-xen.git/commitdiff
xen: use xendevicemodel_make_ram_region_{ro,rw} master vwip
authorIan Campbell <ian.campbell@citrix.com>
Tue, 2 Feb 2016 15:44:09 +0000 (15:44 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 11 Feb 2016 16:16:44 +0000 (16:16 +0000)
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 <ian.campbell@citrix.com>
configure
hw/i386/xen/xen_platform.c
include/hw/xen/xen.h
include/hw/xen/xen_common.h
xen-hvm.c

index b5d9219df3a01a5f8bf4732184541525fe697928..783c49870d5ee16f03ec95ae1bcf6e2bb9b559b7 100755 (executable)
--- 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
index a2247b917ad1c1a00b077ef1f1593a346394f441..154596ff004ace93128a2a0799c89d4aa28359dd 100644 (file)
@@ -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;
     }
index df334818c1bf9d000430d5082bea18f13aa59d9a..5bf47645cf5fc3f5384341182e25e7d27a6abec5 100644 (file)
@@ -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);
 
index 58c479e3884a0773024acfd0ab36eb18be6399b9..565581d64be93401a838de7b5a49434ac6a67411 100644 (file)
@@ -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
 
index a6807a0a1b24899e630a60d54333cd58a9c07809..7220933c213f5fe70a5ec2c7c8f478f29095fc85 100644 (file)
--- 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);
             }
         }