From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4BX3-0000Kk-Vj for qemu-devel@nongnu.org; Fri, 17 Jan 2014 10:40:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W4BWw-0001O9-8C for qemu-devel@nongnu.org; Fri, 17 Jan 2014 10:40:29 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:10112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4BWw-0001Nr-3u for qemu-devel@nongnu.org; Fri, 17 Jan 2014 10:40:22 -0500 From: Stefano Stabellini Date: Fri, 17 Jan 2014 15:39:10 +0000 Message-ID: <1389973152-12997-1-git-send-email-stefano.stabellini@eu.citrix.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PULL 1/3] xenfb: map framebuffer read-only and handle unmap errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: anthony.perard@citrix.com, xen-devel@lists.xen, qemu-devel@nongnu.org, Stefano Stabellini 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(-) 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; -- 1.7.10.4