From patchwork Tue Jan 13 14:25:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 43009 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D070820DE8 for ; Tue, 13 Jan 2015 14:28:29 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf2097028eek.1 for ; Tue, 13 Jan 2015 06:28:29 -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:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=utD8zgmSap2R57xPYUsZJ4c1Vt+cP1yVFqiodrOodzM=; b=UGLHGL7nLWoyO7otkYlhUdkC+coJBwnwuMOumQ6keMVnkRZdyJ7C8Q76w7t0D8v9NQ t00BHDUgh511TxL/a9OAQcVkgpTQwIjdYANjuQ3mY/IPJPRMSN+qIoK6UcM8bZ/wzcBt 651RLvdBetk40+hrg8gMO0P+jrTRMIy12mqNrXVwc+a4FyfCsrha0F+buNt6E8+8AB94 6Mz+IEo/ggGotivvV7549mg+6iQyQyfPQSfOqzlBC1aPHqzhTLgDD6phKLICb+etu65f /ptqWNpu9ko2pphmyW+kr+d5EPkhxlR140/vRwQOFPuKWzCqbBpuO8dFAPGfNqPt97ef tr5g== X-Gm-Message-State: ALoCoQmtoYgAXlwy9AehEJytImlrfiSm6wPjMFuwv9iXkFmySrKKHg2Ogns3p1CQen5IS0b7WZa9 X-Received: by 10.112.13.161 with SMTP id i1mr321720lbc.20.1421159309095; Tue, 13 Jan 2015 06:28:29 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.97 with SMTP id r1ls787089lar.81.gmail; Tue, 13 Jan 2015 06:28:28 -0800 (PST) X-Received: by 10.152.21.134 with SMTP id v6mr42490319lae.13.1421159308889; Tue, 13 Jan 2015 06:28:28 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id uj9si24374065lbb.97.2015.01.13.06.28.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 06:28:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gf13so2876301lab.7 for ; Tue, 13 Jan 2015 06:28:28 -0800 (PST) X-Received: by 10.152.8.11 with SMTP id n11mr40717456laa.38.1421159308794; Tue, 13 Jan 2015 06:28:28 -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.112.9.200 with SMTP id c8csp1398906lbb; Tue, 13 Jan 2015 06:28:28 -0800 (PST) X-Received: by 10.194.78.229 with SMTP id e5mr68562794wjx.11.1421159290540; Tue, 13 Jan 2015 06:28:10 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id cg6si20465065wib.42.2015.01.13.06.28.09 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 13 Jan 2015 06:28:10 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YB2Qz-0001ux-GR; Tue, 13 Jan 2015 14:27:05 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YB2Qu-0001kz-4r for xen-devel@lists.xenproject.org; Tue, 13 Jan 2015 14:27:00 +0000 Received: from [85.158.143.35] by server-3.bemta-4.messagelabs.com id BB/ED-15461-33B25B45; Tue, 13 Jan 2015 14:26:59 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-2.tower-21.messagelabs.com!1421159218!13114253!1 X-Originating-IP: [74.125.82.52] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25635 invoked from network); 13 Jan 2015 14:26:58 -0000 Received: from mail-wg0-f52.google.com (HELO mail-wg0-f52.google.com) (74.125.82.52) by server-2.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 13 Jan 2015 14:26:58 -0000 Received: by mail-wg0-f52.google.com with SMTP id x12so3224455wgg.11 for ; Tue, 13 Jan 2015 06:26:58 -0800 (PST) X-Received: by 10.194.108.9 with SMTP id hg9mr20413806wjb.68.1421159218545; Tue, 13 Jan 2015 06:26:58 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id ni15sm14513482wic.18.2015.01.13.06.26.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jan 2015 06:26:57 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 13 Jan 2015 14:25:32 +0000 Message-Id: <1421159133-31526-24-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421159133-31526-1-git-send-email-julien.grall@linaro.org> References: <1421159133-31526-1-git-send-email-julien.grall@linaro.org> Cc: Wei Liu , ian.campbell@citrix.com, tim@xen.org, Julien Grall , Ian Jackson , stefano.stabellini@citrix.com Subject: [Xen-devel] [PATCH v3 23/24] libxl: Add support for non-PCI passthrough X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) 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 List-Archive: On ARM, every non-PCI device are described in the device tree. Each of them can be found via a path. This patch introduces a very basic support, only the IOMMU will be set up correctly. The user will have to: - Describe the device in the partial device tree - Map manually MMIO/IRQ This is a first approach, that will allow to have a basic non-PCI passthrough support in Xen. This could be improved later. Signed-off-by: Julien Grall Cc: Ian Jackson Cc: Wei Liu --- Changes in v3: - Dynamic allocation has been dropped - Rework the commit message in accordance with the previous item Changes in v2: - Get DT infos earlier - Allocate/map IRQ in libxl__arch_domain_create rather than in libxl__device_dt_add - Use VIRQ rather than the PIRQ to construct the interrupts properties of the device tree - Correct cpumask in make_dtdev_node. We allow the interrupt to be used on the 8 CPUs - Fix LOGE when we map the MMIO region in the guest in libxl__device_dt_add. The domain and the IRQ were inverted - Calculate the number of SPIs to configure the VGIC - xc_physdev_dtdev_* helpers has been renamed to xc_dtdev_* - Rename libxl_device_dt to libxl_device_dtdev --- tools/libxl/Makefile | 2 +- tools/libxl/libxl_create.c | 10 ++++++++++ tools/libxl/libxl_dtdev.c | 34 ++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 5 +++++ tools/libxl/libxl_types.idl | 5 +++++ 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_dtdev.c diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index b417372..98e1bab 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -96,7 +96,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ libxl_json.o libxl_aoutils.o libxl_numa.o \ libxl_save_callout.o _libxl_save_msgs_callout.o \ libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y) -LIBXL_OBJS += libxl_genid.o +LIBXL_OBJS += libxl_genid.o libxl_dtdev.o LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o LIBXL_TESTS += timedereg diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 029d2e2..b7ef528 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1430,6 +1430,16 @@ static void domcreate_attach_pci(libxl__egc *egc, libxl__multidev *multidev, } } + for (i = 0; i < d_config->num_dtdevs; i++) { + + ret = libxl__device_dt_add(gc, domid, &d_config->dtdevs[i]); + if (ret < 0) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "libxl__device_dt_add failed: %d\n", ret); + goto error_out; + } + } + domcreate_console_available(egc, dcs); domcreate_complete(egc, dcs, 0); diff --git a/tools/libxl/libxl_dtdev.c b/tools/libxl/libxl_dtdev.c new file mode 100644 index 0000000..5de57f0 --- /dev/null +++ b/tools/libxl/libxl_dtdev.c @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2014 Linaro Limited. + * Author Julien Grall + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file 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 Lesser General Public License for more details. + */ + +#include "libxl_osdeps.h" /* Must come before other headers */ + +#include "libxl_internal.h" + +int libxl__device_dt_add(libxl__gc *gc, uint32_t domid, + const libxl_device_dtdev *dtdev) +{ + LOG(DEBUG, "Assign device \"%s\" to dom%u", dtdev->path, domid); + + return xc_assign_dt_device(CTX->xch, domid, dtdev->path); +} + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index be5ed82..c00516a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1179,6 +1179,11 @@ _hidden int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int num); _hidden int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t domid); +/* from libxl_dtdev */ + +_hidden int libxl__device_dt_add(libxl__gc *gc, uint32_t domid, + const libxl_device_dtdev *dtdev); + /*----- xswait: wait for a xenstore node to be suitable -----*/ typedef struct libxl__xswait_state libxl__xswait_state; diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 5651110..c10fd2f 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -522,6 +522,10 @@ libxl_device_pci = Struct("device_pci", [ ("seize", bool), ]) +libxl_device_dtdev = Struct("device_dtdev", [ + ("path", string), + ]) + libxl_device_vtpm = Struct("device_vtpm", [ ("backend_domid", libxl_domid), ("backend_domname", string), @@ -548,6 +552,7 @@ libxl_domain_config = Struct("domain_config", [ ("disks", Array(libxl_device_disk, "num_disks")), ("nics", Array(libxl_device_nic, "num_nics")), ("pcidevs", Array(libxl_device_pci, "num_pcidevs")), + ("dtdevs", Array(libxl_device_dtdev, "num_dtdevs")), ("vfbs", Array(libxl_device_vfb, "num_vfbs")), ("vkbs", Array(libxl_device_vkb, "num_vkbs")), ("vtpms", Array(libxl_device_vtpm, "num_vtpms")),