From patchwork Mon Nov 1 15:01:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 69789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by ozlabs.org (Postfix) with ESMTP id AE042B6F10 for ; Tue, 2 Nov 2010 02:36:47 +1100 (EST) Received: from localhost ([127.0.0.1]:36254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PCwMC-0003zr-B9 for incoming@patchwork.ozlabs.org; Mon, 01 Nov 2010 11:31:36 -0400 Received: from [140.186.70.92] (port=53009 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PCvtx-0003mw-R9 for qemu-devel@nongnu.org; Mon, 01 Nov 2010 11:02:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PCvtX-0000h6-4q for qemu-devel@nongnu.org; Mon, 01 Nov 2010 11:02:06 -0400 Received: from cantor.suse.de ([195.135.220.2]:60267 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PCvtW-0000g9-Oz for qemu-devel@nongnu.org; Mon, 01 Nov 2010 11:01:58 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id A475E94A12; Mon, 1 Nov 2010 16:01:54 +0100 (CET) From: Alexander Graf To: qemu-devel Developers Date: Mon, 1 Nov 2010 16:01:42 +0100 Message-Id: <1288623713-28062-30-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1288623713-28062-1-git-send-email-agraf@suse.de> References: <1288623713-28062-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 29/40] xenner: libxc emu: grant tables X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Xenner emulates parts of libxc, so we can not use the real xen infrastructure when running xen pv guests without xen. This patch adds support for grant tables. Signed-off-by: Alexander Graf --- hw/xenner_libxc_gnttab.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 91 insertions(+), 0 deletions(-) create mode 100644 hw/xenner_libxc_gnttab.c diff --git a/hw/xenner_libxc_gnttab.c b/hw/xenner_libxc_gnttab.c new file mode 100644 index 0000000..c9f4ce2 --- /dev/null +++ b/hw/xenner_libxc_gnttab.c @@ -0,0 +1,91 @@ +/* + * Copyright (C) Red Hat 2007 + * Copyright (C) Novell Inc. 2010 + * + * Author(s): Gerd Hoffmann + * Alexander Graf + * + * Xenner Emulation -- grant tables + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include +#include + +#include "hw.h" +#include "xen_interfaces.h" +#include "xenner.h" + +/* ------------------------------------------------------------- */ + +static grant_entry_v1_t *get_grant(uint32_t ref) +{ + grant_entry_v1_t *e; + int page, index; + + page = ref / (PAGE_SIZE / sizeof(grant_entry_v1_t)); + index = ref % (PAGE_SIZE / sizeof(grant_entry_v1_t)); + + e = xenner_get_grant_table(page); + if (!e) { + return NULL; + } + return e + index; +} + +/* ------------------------------------------------------------- */ + +static int _qemu_open(void) +{ + return 42; +} + +static int qemu_close(int xcg_handle) +{ + return 0; +} + +static void *qemu_map_grant_ref(int xcg_handle, uint32_t domid, + uint32_t ref, int prot) +{ + grant_entry_v1_t *e; + + e = get_grant(ref); + if (!e) { + return NULL; + } + + return xenner_mfn_to_ptr(e->frame); +} + +static void *qemu_map_grant_refs(int xcg_handle, uint32_t count, + uint32_t *domids, uint32_t *refs, int prot) +{ + /* Hmm, not so easy ... */ + return NULL; +} + +static int qemu_munmap(int xcg_handle, void *start_address, uint32_t count) +{ + /* nothing as we didn't actually map anything ... */ + return 0; +} + +struct XenGnttabOps xc_gnttab_xenner = { + .open = _qemu_open, + .close = qemu_close, + .map_grant_ref = qemu_map_grant_ref, + .map_grant_refs = qemu_map_grant_refs, + .munmap = qemu_munmap, +};