From patchwork Fri Jan 17 15:39:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 23343 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A9912202DA for ; Fri, 17 Jan 2014 15:42:50 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id w17sf6488414vbj.9 for ; Fri, 17 Jan 2014 07:42:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type; bh=GeJcS1IGYsDEAWfgMr5FDgHvBRWPqI/OpFNSQP+iIVU=; b=cyLKiNFIuKvr8ptbDH9j+QQewhUDVFHdYNLfo8vOL3gcsikc0b4M+M+8F033+5kZeQ VUOBOKvv/9ff6xYw7zTvSoJ688V3rl+haDVTyAR5RsNPs/BDgiAeIwuTMVOgtXLdNwb5 8UIyKVicqp3IFWuvQgjip2ImlWgiPqNX2O8nZRJFVmoJpAnr5W+h/ReEkUcNsQ8W003f jLr410bo0VAhc9VCpsnBPy3v/ikj6VZQ4adlUvHkp9w6JNnDD6891HCYFtYufueS0nmL VJAp9gT1/TUqPGYz4R6oY4U9C6RJE8ECVerU2RAWp9cUv1r39DpPvq5WbAWw2fmf8XfR zklQ== X-Gm-Message-State: ALoCoQnQXjjCVjkDZSbKF/AGi8N3j46Di2gG3cEvoCsE1du/iAM1UaxEptgKgJixVmIEwr/aFrQ/ X-Received: by 10.58.249.180 with SMTP id yv20mr804599vec.11.1389973369867; Fri, 17 Jan 2014 07:42:49 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.109.8 with SMTP id ho8ls99875qeb.76.gmail; Fri, 17 Jan 2014 07:42:49 -0800 (PST) X-Received: by 10.52.166.6 with SMTP id zc6mr1074587vdb.10.1389973369755; Fri, 17 Jan 2014 07:42:49 -0800 (PST) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx.google.com with ESMTPS id gq3si5042649vdc.132.2014.01.17.07.42.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 07:42:49 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.54; Received: by mail-vb0-f54.google.com with SMTP id w20so1642262vbb.13 for ; Fri, 17 Jan 2014 07:42:49 -0800 (PST) X-Received: by 10.220.139.136 with SMTP id e8mr550606vcu.34.1389973369669; Fri, 17 Jan 2014 07:42:49 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp28856ved; Fri, 17 Jan 2014 07:42:49 -0800 (PST) X-Received: by 10.229.194.1 with SMTP id dw1mr4330306qcb.20.1389973369213; Fri, 17 Jan 2014 07:42:49 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t101si290750qge.51.2014.01.17.07.42.49 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 17 Jan 2014 07:42:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:38900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4BZI-0003BO-Rz for patch@linaro.org; Fri, 17 Jan 2014 10:42:48 -0500 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 X-IronPort-AV: E=Sophos;i="4.95,674,1384300800"; d="scan'208";a="91803342" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 17 Jan 2014 15:40:21 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.2.342.4; Fri, 17 Jan 2014 10:40:20 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1W4BWo-0002SE-Ry; Fri, 17 Jan 2014 15:40:14 +0000 From: Stefano Stabellini To: Date: Fri, 17 Jan 2014 15:39:10 +0000 Message-ID: <1389973152-12997-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: anthony.perard@citrix.com, xen-devel@lists.xen, qemu-devel@nongnu.org, Stefano Stabellini Subject: [Qemu-devel] [PULL 1/3] xenfb: map framebuffer read-only and handle unmap errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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;