From patchwork Thu Mar 19 19:29:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 46095 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4EE7E21515 for ; Thu, 19 Mar 2015 19:32:18 +0000 (UTC) Received: by labgq15 with SMTP id gq15sf14244361lab.0 for ; Thu, 19 Mar 2015 12:32:17 -0700 (PDT) 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=y0mmCPp35uBp+2KO3Ihkhynxjp2WTun+bILe3LcP1oY=; b=byRguCHFTvb0Ntx7mIUG2eBFiPebp7ReWzqelIsdUM9HkA97FKnMkUPZKyq2Z7iVQO NbNK9CAIoRDqrut8uqlHuAkMHJsgMLZpwG4yp4IjZeuOr3HlbzjSppulRk4sSQb41iot qxQPz+ao0pX4yEdc+DR8ZiVQi7P7pO+OzwQWro+ydGVP1f5ACyagrp6zhkZlnxdclXGW HUXXZJyEwAALvP5LbwHVUWYpzg2SkIYFVbKwOWtn7MpGVA8qJ2nWp2Xpho1wHwB0fs3p NInDy4mSAzEP4MENZGL1eeymbc3pf2sjlnBK3tshFB71RUpaXxThg+VplAuuRWCCJg/L pW/g== X-Gm-Message-State: ALoCoQl9/jh+Nw8VFRwI5hnwQtezyS/DTPGW1lMcuKU09sVhLytrXzC7GxetbohZkN+Etn0L7AUx X-Received: by 10.112.97.37 with SMTP id dx5mr3650637lbb.15.1426793537312; Thu, 19 Mar 2015 12:32:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.201 with SMTP id n9ls349916lag.41.gmail; Thu, 19 Mar 2015 12:32:17 -0700 (PDT) X-Received: by 10.152.23.133 with SMTP id m5mr44853977laf.71.1426793537090; Thu, 19 Mar 2015 12:32:17 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id q3si1704153lag.1.2015.03.19.12.32.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2015 12:32:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lagg8 with SMTP id g8so70656438lag.1 for ; Thu, 19 Mar 2015 12:32:17 -0700 (PDT) X-Received: by 10.152.116.11 with SMTP id js11mr48314687lab.106.1426793536972; Thu, 19 Mar 2015 12:32:16 -0700 (PDT) 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.35.133 with SMTP id h5csp597497lbj; Thu, 19 Mar 2015 12:32:16 -0700 (PDT) X-Received: by 10.52.163.37 with SMTP id yf5mr52719484vdb.45.1426793533236; Thu, 19 Mar 2015 12:32:13 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id fp2si1990768vdb.39.2015.03.19.12.32.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 19 Mar 2015 12:32:13 -0700 (PDT) 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 1YYgAD-0005ao-Il; Thu, 19 Mar 2015 19:31:29 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YYgAB-0005St-5O for xen-devel@lists.xenproject.org; Thu, 19 Mar 2015 19:31:27 +0000 Received: from [193.109.254.147] by server-3.bemta-14.messagelabs.com id 96/1B-21221-E042B055; Thu, 19 Mar 2015 19:31:26 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1426793485!14424072!1 X-Originating-IP: [209.85.212.170] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7805 invoked from network); 19 Mar 2015 19:31:25 -0000 Received: from mail-wi0-f170.google.com (HELO mail-wi0-f170.google.com) (209.85.212.170) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 19 Mar 2015 19:31:25 -0000 Received: by wixw10 with SMTP id w10so15111359wix.0 for ; Thu, 19 Mar 2015 12:31:25 -0700 (PDT) X-Received: by 10.194.61.244 with SMTP id t20mr148896439wjr.83.1426793484279; Thu, 19 Mar 2015 12:31:24 -0700 (PDT) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id hl8sm3203005wjb.38.2015.03.19.12.31.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Mar 2015 12:31:23 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 19 Mar 2015 19:29:57 +0000 Message-Id: <1426793399-6283-32-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1426793399-6283-1-git-send-email-julien.grall@linaro.org> References: <1426793399-6283-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 v4 31/33] 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.46 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. Furthermore add LIBXL_HAVE_DEVICETREE_PASSTHROUGH to indicate we support non-PCI passthrough and partial device tree (introduced by a previous patch). Signed-off-by: Julien Grall Cc: Ian Jackson Cc: Wei Liu --- Changes in v4: - Add LIBXL_HAVE_DEVICTREE_PASSTHROUGH to indicate we support non-PCI passthrough. This is also used in order to indicate partial device tree is supported - Remove libxl_dtdev.c as it contains only a 2 lines functions and call directly xc_* from libxl_create.c - Introduce domcreate_attach_dtdev 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/libxl.h | 6 ++++++ tools/libxl/libxl_create.c | 32 ++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 5 +++++ tools/libxl/libxl_types.idl | 5 +++++ 4 files changed, 48 insertions(+) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 6bc75c5..baaf06b 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -179,6 +179,12 @@ #define LIBXL_HAVE_BUILDINFO_HVM_MMIO_HOLE_MEMKB 1 /* + * libxl_domain_build_info has device_tree and libxl_device_dtdev + * exists. This mean non-PCI passthrough is supported for ARM + */ +#define LIBXL_HAVE_DEVICETREE_PASSTHROUGH 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 15b464e..39c828b 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -751,6 +751,8 @@ static void domcreate_attach_vtpms(libxl__egc *egc, libxl__multidev *multidev, int ret); static void domcreate_attach_pci(libxl__egc *egc, libxl__multidev *aodevs, int ret); +static void domcreate_attach_dtdev(libxl__egc *egc, + libxl__domain_create_state *dcs); static void domcreate_console_available(libxl__egc *egc, libxl__domain_create_state *dcs); @@ -1444,6 +1446,36 @@ static void domcreate_attach_pci(libxl__egc *egc, libxl__multidev *multidev, } } + domcreate_attach_dtdev(egc, dcs); + return; + +error_out: + assert(ret); + domcreate_complete(egc, dcs, ret); +} + +static void domcreate_attach_dtdev(libxl__egc *egc, + libxl__domain_create_state *dcs) +{ + STATE_AO_GC(dcs->ao); + int i; + int ret; + int domid = dcs->guest_domid; + + /* convenience aliases */ + libxl_domain_config *const d_config = dcs->guest_config; + + for (i = 0; i < d_config->num_dtdevs; i++) { + const libxl_device_dtdev *dtdev = &d_config->dtdevs[i]; + + LOG(DEBUG, "Assign device \"%s\" to dom%u", dtdev->path, domid); + ret = xc_assign_dt_device(CTX->xch, domid, dtdev->path); + if (ret < 0) { + LOG(ERROR, "xc_assign_dtdevice failed: %d\n", ret); + goto error_out; + } + } + domcreate_console_available(egc, dcs); domcreate_complete(egc, dcs, 0); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 46fa624..1191098 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1198,6 +1198,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 c97e6ed..2ab8587 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -534,6 +534,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), @@ -560,6 +564,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")),