From patchwork Wed Sep 10 13:42:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Owen Smith X-Patchwork-Id: 387918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DF31F14011D for ; Thu, 11 Sep 2014 04:28:13 +1000 (EST) Received: from localhost ([::1]:58114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRmcl-0000Ef-0v for incoming@patchwork.ozlabs.org; Wed, 10 Sep 2014 14:28:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRiBU-0001MX-26 for qemu-devel@nongnu.org; Wed, 10 Sep 2014 09:43:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRiBI-0000XG-Ch for qemu-devel@nongnu.org; Wed, 10 Sep 2014 09:43:44 -0400 Received: from smtp.citrix.com ([66.165.176.89]:19074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRiBI-0000Wt-8o for qemu-devel@nongnu.org; Wed, 10 Sep 2014 09:43:32 -0400 X-IronPort-AV: E=Sophos;i="5.04,499,1406592000"; d="scan'208";a="170152844" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Wed, 10 Sep 2014 09:43:06 -0400 Received: from dt05.uk.xensource.com ([10.80.227.144] helo=dt05.uk.xensource.com.) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XRiAs-0002XP-A8; Wed, 10 Sep 2014 14:43:06 +0100 From: Owen smith To: Date: Wed, 10 Sep 2014 14:42:25 +0100 Message-ID: <1410356546-22264-3-git-send-email-owen.smith@citrix.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1410356546-22264-1-git-send-email-owen.smith@citrix.com> References: <1410356546-22264-1-git-send-email-owen.smith@citrix.com> 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.89 X-Mailman-Approved-At: Wed, 10 Sep 2014 14:26:28 -0400 Cc: stefano.stabellini@eu.citrix.com, Owen smith , xen-devel@lists.xen.org Subject: [Qemu-devel] [PATCH 2/3] xenfb: Add option to use grant ref for shared page. 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The vkbd device should be able to use a grant reference to map the shared page. Signed-off-by: Owen smith --- hw/display/xenfb.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 2c39753..c4375c8 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -54,6 +54,7 @@ struct common { struct XenDevice xendev; /* must be first */ void *page; + int page_gref; QemuConsole *con; }; @@ -96,22 +97,36 @@ static int common_bind(struct common *c) { uint64_t mfn; - if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) == -1) - return -1; - assert(mfn == (xen_pfn_t)mfn); - if (xenstore_read_fe_int(&c->xendev, "event-channel", &c->xendev.remote_port) == -1) return -1; - c->page = xc_map_foreign_range(xen_xc, c->xendev.dom, - XC_PAGE_SIZE, - PROT_READ | PROT_WRITE, mfn); + if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) == -1) { + if (xenstore_read_fe_int(&c->xendev, "page-gref", &c->page_gref) == -1) { + return -1; + } + c->page = xc_gnttab_map_grant_ref(c->xendev.gnttabdev, + c->xendev.dom, + c->page_gref, + PROT_READ | PROT_WRITE); + } else { + assert(mfn == (xen_pfn_t)mfn); + + c->page = xc_map_foreign_range(xen_xc, c->xendev.dom, + XC_PAGE_SIZE, + PROT_READ | PROT_WRITE, mfn); + } if (c->page == NULL) return -1; xen_be_bind_evtchn(&c->xendev); - xen_be_printf(&c->xendev, 1, "ring mfn %"PRIx64", remote-port %d, local-port %d\n", - mfn, c->xendev.remote_port, c->xendev.local_port); + + if (c->page_gref) { + xen_be_printf(&c->xendev, 1, "ring gref %d, remote-port %d, local-port %d\n", + c->page_gref, c->xendev.remote_port, c->xendev.local_port); + } else { + xen_be_printf(&c->xendev, 1, "ring mfn %"PRIx64", remote-port %d, local-port %d\n", + mfn, c->xendev.remote_port, c->xendev.local_port); + } return 0; } @@ -120,8 +135,13 @@ static void common_unbind(struct common *c) { xen_be_unbind_evtchn(&c->xendev); if (c->page) { - munmap(c->page, XC_PAGE_SIZE); + if (c->page_gref) { + xc_gnttab_munmap(c->xendev.gnttabdev, c->page, 1); + } else { + munmap(c->page, XC_PAGE_SIZE); + } c->page = NULL; + c->page_gref = 0; } } @@ -954,6 +974,7 @@ static void fb_event(struct XenDevice *xendev) struct XenDevOps xen_kbdmouse_ops = { .size = sizeof(struct XenInput), + .flags = DEVOPS_FLAG_NEED_GNTDEV, .init = input_init, .initialise = input_initialise, .connected = input_connected,