From patchwork Thu Oct 10 14:12:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 11183669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D725E17EE for ; Thu, 10 Oct 2019 14:14:18 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B284C206A1 for ; Thu, 10 Oct 2019 14:14:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H2RJeAef" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B284C206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iIZBN-00008k-Qs; Thu, 10 Oct 2019 14:12:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iIZBM-00008f-F1 for xen-devel@lists.xenproject.org; Thu, 10 Oct 2019 14:12:44 +0000 X-Inumbo-ID: 0675c5d4-eb68-11e9-a531-bc764e2007e4 Received: from mail-lf1-x144.google.com (unknown [2a00:1450:4864:20::144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0675c5d4-eb68-11e9-a531-bc764e2007e4; Thu, 10 Oct 2019 14:12:43 +0000 (UTC) Received: by mail-lf1-x144.google.com with SMTP id t8so4478437lfc.13 for ; Thu, 10 Oct 2019 07:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=tHVNfKcoCCgRGpHvQ2CBeSdDo+ljTpuAZA/KupRCU1s=; b=H2RJeAefbAriAht9HtmSwWxnZO7K/gmvqxZjaRBPLn9VaeYKBRPl441896dysH2Zw8 XWb8BR5/dLZbMgEPSnnU+i1toUdMZRpHNVCLE87/wUB6UNgSPxx0O5iMsYdQj++C+Zef evE5lz0RrHtg5HCfFNy1ny7e1FQ0M6+R7zRXZDSnyMAJgbynVD+J8Eo3UPdFVBgYrKlP 6sAZgs9nkDmtdVOZ9O+kVD5QD75z2DnEPYuYtUtepjKSqsVgM4XfGXHx3RLVz6Y7z7ex J5MEHDeBXyNOArHB4nFN4yJi75DxgkShpydt1p9vjplTEmbhHgilpTPgilNgeoWfy2/b whSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tHVNfKcoCCgRGpHvQ2CBeSdDo+ljTpuAZA/KupRCU1s=; b=MX7FZ2q9CAMDRoU4+dX2DDBMOaqbZdqpjtcTudNJUYkQqTbozlJ8dr5X6SZcWZOeTd GbKDZRQBwObKjjKqtbL1K/NvN+ED9INY66EwLMQqxCe1s4cGFbEgruxRKqrYcokBzq4n y0ybrOp3Xl/RyiHphF0AQPOtBCaUvQ5XquXiQY8n0JNI/NKOtx2Klp/7i/blKOmppBv/ ecsWqf3zf7X/n6DZrQL3/8jAVIf2MYfNbqDnupPEOJZ+GQ0pZoj90WZ/CYz1ZE9cMx4S RuDWvemUsmlEGUkAeO1rjaYYcciQtq3/BoioJ4dxI4fxwQN9w1Tg76azA1/8nYTLOmcO +W+g== X-Gm-Message-State: APjAAAW+7rchxQsRcUKMb1wlUSCq7QSoEfjbNRv5VmSI4hYT+avgnpVv mUw+hAuCjJSCBXU+JWWrXKe4xfCe6a5kmQ== X-Google-Smtp-Source: APXvYqyldasoVJgdJi02sBr1o7OYS0NKR0vfixwiws4qo5DbudetZOiqism0y9AxKBiZfgHCBRnaCw== X-Received: by 2002:ac2:533c:: with SMTP id f28mr6076035lfh.77.1570716762131; Thu, 10 Oct 2019 07:12:42 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id q5sm1387549lfm.93.2019.10.10.07.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 07:12:41 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Thu, 10 Oct 2019 17:12:31 +0300 Message-Id: <20191010141231.25363-1-al1img@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH v1] libxl: Add DTB compatible list to config file X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Grytsov , Iurii Konovalenko , ian.jackson@eu.citrix.com, wl@xen.org, Oleksandr Andrushchenko MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Grytsov Some platforms need more compatible property values in device tree root node in addition to "xen,xenvm-%d.%d" and "xen,xenvm" values that are given by Xen by default. Specify in domain configuration file which values should be added by providing "dtb_compatible" list of strings separated by comas. Signed-off-by: Iurii Konovalenko Signed-off-by: Oleksandr Andrushchenko --- tools/libxl/libxl_arm.c | 42 ++++++++++++++++++++++++++++++------- tools/libxl/libxl_types.idl | 1 + tools/xl/xl_parse.c | 7 +++++++ 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index bf31b9b3ca..b956a6356c 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -270,20 +270,46 @@ static int fdt_property_regs(libxl__gc *gc, void *fdt, static int make_root_properties(libxl__gc *gc, const libxl_version_info *vers, - void *fdt) + void *fdt, + const libxl_domain_build_info *info) { - int res; + const char *compat0 = GCSPRINTF("xen,xenvm-%d.%d", + vers->xen_version_major, + vers->xen_version_minor); + const char *compat1 = "xen,xenvm"; + const char **compats; + char *compat, *p; + size_t sz = 0; + int i, res, num_compats; res = fdt_property_string(fdt, "model", GCSPRINTF("XENVM-%d.%d", vers->xen_version_major, vers->xen_version_minor)); if (res) return res; - res = fdt_property_compat(gc, fdt, 2, - GCSPRINTF("xen,xenvm-%d.%d", - vers->xen_version_major, - vers->xen_version_minor), - "xen,xenvm"); + num_compats = 2 + libxl_string_list_length(&info->dt_compatible); + compats = libxl__zalloc(gc, num_compats * sizeof(*compats)); + if (!compats) + return -FDT_ERR_INTERNAL; + + compats[0] = compat0; + compats[1] = compat1; + sz = strlen(compat0) + strlen(compat1) + 2; + for (i = 0; info->dt_compatible && info->dt_compatible[i] != NULL; i++) { + compats[2 + i] = info->dt_compatible[i]; + sz += strlen(info->dt_compatible[i]) + 1; + } + + p = compat = libxl__zalloc(gc, sz); + if (!p) + return -FDT_ERR_INTERNAL; + + for (i = 0; i < num_compats; i++) { + strcpy(p, compats[i]); + p += strlen(compats[i]) + 1; + } + + res = fdt_property(fdt, "compatible", compat, sz); if (res) return res; res = fdt_property_cell(fdt, "interrupt-parent", GUEST_PHANDLE_GIC); @@ -930,7 +956,7 @@ next_resize: FDT( fdt_begin_node(fdt, "") ); - FDT( make_root_properties(gc, vers, fdt) ); + FDT( make_root_properties(gc, vers, fdt, info) ); FDT( make_chosen_node(gc, fdt, !!dom->modules[0].blob, state, info) ); FDT( make_cpus_node(gc, fdt, info->max_vcpus, ainfo) ); FDT( make_psci_node(gc, fdt) ); diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 3ac9494b80..08ffb65904 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -544,6 +544,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ # Note that the partial device tree should avoid to use the phandle # 65000 which is reserved by the toolstack. ("device_tree", string), + ("dt_compatible", libxl_string_list), ("acpi", libxl_defbool), ("bootloader", string), ("bootloader_args", libxl_string_list), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 03a2c54dd2..db9821c765 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2408,6 +2408,13 @@ skip_vfb: } } + e = xlu_cfg_get_list_as_string_list(config, "dt_compatible", + &b_info->dt_compatible, 1); + if (e && e != ESRCH) { + fprintf(stderr,"xl: Unable to parse dt_compatible\n"); + exit(-ERROR_FAIL); + } + if (!xlu_cfg_get_list(config, "usbctrl", &usbctrls, 0, 0)) { d_config->num_usbctrls = 0; d_config->usbctrls = NULL;