[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 23/24] libxl: Add support for non-PCI passthrough
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 <julien.grall@xxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> --- 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 <julien.grall@xxxxxxxxxx> + * + * 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")), -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |