From 0193c62c94643a837832f2b5ccc133434ee740cb Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Fri, 17 Jan 2014 15:28:18 +0000 Subject: xenfb: map framebuffer read-only and handle unmap errors The framebuffer is needlessly mapped (PROT_READ | PROT_WRITE), map it PROT_READ instead. The framebuffer is unmapped by replacing the framebuffer pages with anonymous shared memory, calling mmap. Check for return errors and print a warning. Signed-off-by: Stefano Stabellini --- hw/display/xenfb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index f0333a0..cb9d456 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -495,7 +495,7 @@ static int xenfb_map_fb(struct XenFB *xenfb) munmap(map, n_fbdirs * XC_PAGE_SIZE); xenfb->pixels = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom, - PROT_READ | PROT_WRITE, fbmfns, xenfb->fbpages); + PROT_READ, fbmfns, xenfb->fbpages); if (xenfb->pixels == NULL) goto out; @@ -903,6 +903,11 @@ static void fb_disconnect(struct XenDevice *xendev) fb->pixels = mmap(fb->pixels, fb->fbpages * XC_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); + if (fb->pixels == MAP_FAILED) { + xen_be_printf(xendev, 0, + "Couldn't replace the framebuffer with anonymous memory errno=%d\n", + errno); + } common_unbind(&fb->c); fb->feature_update = 0; fb->bug_trigger = 0; -- cgit v1.1 From fc33b9004c49f21f8188df5c4cd079a9a3d08de8 Mon Sep 17 00:00:00 2001 From: Anthony PERARD Date: Fri, 10 Jan 2014 15:52:54 +0000 Subject: xen_pt: Fix debug output. Signed-off-by: Anthony PERARD Signed-off-by: Stefano Stabellini Reviewed-by: Konrad Rzeszutek Wilk --- hw/xen/xen_pt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index d58cb61..eee4354 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -420,8 +420,8 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s) "xen-pci-pt-bar", r->size); pci_register_bar(&s->dev, i, type, &s->bar[i]); - XEN_PT_LOG(&s->dev, "IO region %i registered (size=0x%lx"PRIx64 - " base_addr=0x%lx"PRIx64" type: %#x)\n", + XEN_PT_LOG(&s->dev, "IO region %i registered (size=0x%08"PRIx64 + " base_addr=0x%08"PRIx64" type: %#x)\n", i, r->size, r->base_addr, type); } -- cgit v1.1 From 794798e36eda77802ce7cc7d7d6b1c65751e8a76 Mon Sep 17 00:00:00 2001 From: Anthony PERARD Date: Fri, 10 Jan 2014 15:56:33 +0000 Subject: xen_pt: Fix passthrough of device with ROM. QEMU does not need and should not allocate memory for the ROM of a passthrough PCI device. So this patch initialize the particular region like any other PCI BAR of a passthrough device. When a guest will access the ROM, Xen will take care of the IO, QEMU will not be involved in it. Xen set a limit of memory available for each guest, allocating memory for a ROM can hit this limit. Signed-off-by: Anthony PERARD Signed-off-by: Stefano Stabellini Reported-and-Tested-by: Konrad Rzeszutek Wilk --- hw/xen/xen_pt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index eee4354..be4220b 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -440,8 +440,8 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s) s->bases[PCI_ROM_SLOT].access.maddr = d->rom.base_addr; - memory_region_init_rom_device(&s->rom, OBJECT(s), NULL, NULL, - "xen-pci-pt-rom", d->rom.size); + memory_region_init_io(&s->rom, OBJECT(s), &ops, &s->dev, + "xen-pci-pt-rom", d->rom.size); pci_register_bar(&s->dev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->rom); -- cgit v1.1