From patchwork Fri Oct 4 01:14:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 11173585 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 ADE4A1599 for ; Fri, 4 Oct 2019 01:16:22 +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 8833E208E3 for ; Fri, 4 Oct 2019 01:16:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="uJew00yb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8833E208E3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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 1iGCBS-0003KU-GC; Fri, 04 Oct 2019 01:15:02 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iGCBR-0003KJ-Qy for xen-devel@lists.xen.org; Fri, 04 Oct 2019 01:15:01 +0000 X-Inumbo-ID: 62a02ec3-e644-11e9-973b-12813bfff9fa Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 62a02ec3-e644-11e9-973b-12813bfff9fa; Fri, 04 Oct 2019 01:15:00 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D1D1321783; Fri, 4 Oct 2019 01:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570151700; bh=4P9vHs+x0x+Ba1j0nqm9pex9XW2hcInSe5HSIg/Na7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uJew00yb1NLtmrk5xbZqYZCgL3PjOSQevEGigZ1Gs8xJDlRumCF2dmS6GGwq4x7wV QIDEMGOF7H6274gHTwXblM1Wl+Z+UcwCa9ocuk2gG78pdR8KBwvkHc1zP0g+ZjWI6i +1Yb15R3etZZtCkWXCNFrB/QucIK2DK2dJ5f+NUE= From: Stefano Stabellini To: julien.grall@arm.com Date: Thu, 3 Oct 2019 18:14:52 -0700 Message-Id: <20191004011457.11126-3-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v9 3/8] xen/arm: introduce kinfo->phandle_gic 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: Stefano Stabellini , sstabellini@kernel.org, andrii_anisov@epam.com, Achin.Gupta@arm.com, xen-devel@lists.xen.org, Volodymyr_Babchuk@epam.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Instead of always hard-coding the GIC phandle (GUEST_PHANDLE_GIC), store it in a variable under kinfo. This way it can be dynamically chosen per domain. Remove the fdt pointer argument to the make_*_domU_node functions and oass a struct kernel_info * instead. The fdt pointer can be accessed from kinfo->fdt. Remove the struct domain *d parameter to the make_*_domU_node functions because it becomes unused. Initialize phandle_gic to GUEST_PHANDLE_GIC at the beginning of prepare_dtb_domU for DomUs. Later patches will change the value of phandle_gic depending on user provided information. For Dom0, initialize phandle_gic to dt_interrupt_controller->phandle (current value) at the beginning of prepare_dtb. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v6: - rename guest_phandle_gic to phandle_gic - use phandle_gic for dom0 too Changes in v5: - improve commit message Changes in v4: - new patch --- xen/arch/arm/domain_build.c | 39 ++++++++++++++++++++---------------- xen/include/asm-arm/kernel.h | 3 +++ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index fb356603e2..d23c0a9b87 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -626,15 +626,14 @@ static int __init fdt_property_interrupts(const struct kernel_info *kinfo, unsigned num_irq) { int res; - uint32_t phandle = is_hardware_domain(kinfo->d) ? - dt_interrupt_controller->phandle : GUEST_PHANDLE_GIC; res = fdt_property(kinfo->fdt, "interrupts", intr, sizeof(intr[0]) * num_irq); if ( res ) return res; - res = fdt_property_cell(kinfo->fdt, "interrupt-parent", phandle); + res = fdt_property_cell(kinfo->fdt, "interrupt-parent", + kinfo->phandle_gic); return res; } @@ -1552,8 +1551,9 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, return res; } -static int __init make_gicv2_domU_node(const struct domain *d, void *fdt) +static int __init make_gicv2_domU_node(struct kernel_info *kinfo) { + void *fdt = kinfo->fdt; int res = 0; __be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2]; __be32 *cells; @@ -1588,11 +1588,11 @@ static int __init make_gicv2_domU_node(const struct domain *d, void *fdt) if (res) return res; - res = fdt_property_cell(fdt, "linux,phandle", GUEST_PHANDLE_GIC); + res = fdt_property_cell(fdt, "linux,phandle", kinfo->phandle_gic); if (res) return res; - res = fdt_property_cell(fdt, "phandle", GUEST_PHANDLE_GIC); + res = fdt_property_cell(fdt, "phandle", kinfo->phandle_gic); if (res) return res; @@ -1601,8 +1601,9 @@ static int __init make_gicv2_domU_node(const struct domain *d, void *fdt) return res; } -static int __init make_gicv3_domU_node(const struct domain *d, void *fdt) +static int __init make_gicv3_domU_node(struct kernel_info *kinfo) { + void *fdt = kinfo->fdt; int res = 0; __be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2]; __be32 *cells; @@ -1637,11 +1638,11 @@ static int __init make_gicv3_domU_node(const struct domain *d, void *fdt) if (res) return res; - res = fdt_property_cell(fdt, "linux,phandle", GUEST_PHANDLE_GIC); + res = fdt_property_cell(fdt, "linux,phandle", kinfo->phandle_gic); if (res) return res; - res = fdt_property_cell(fdt, "phandle", GUEST_PHANDLE_GIC); + res = fdt_property_cell(fdt, "phandle", kinfo->phandle_gic); if (res) return res; @@ -1650,22 +1651,23 @@ static int __init make_gicv3_domU_node(const struct domain *d, void *fdt) return res; } -static int __init make_gic_domU_node(const struct domain *d, void *fdt) +static int __init make_gic_domU_node(struct kernel_info *kinfo) { - switch ( d->arch.vgic.version ) + switch ( kinfo->d->arch.vgic.version ) { case GIC_V3: - return make_gicv3_domU_node(d, fdt); + return make_gicv3_domU_node(kinfo); case GIC_V2: - return make_gicv2_domU_node(d, fdt); + return make_gicv2_domU_node(kinfo); default: panic("Unsupported GIC version\n"); } } #ifdef CONFIG_SBSA_VUART_CONSOLE -static int __init make_vpl011_uart_node(const struct domain *d, void *fdt) +static int __init make_vpl011_uart_node(struct kernel_info *kinfo) { + void *fdt = kinfo->fdt; int res; gic_interrupt_t intr; __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS]; @@ -1696,7 +1698,7 @@ static int __init make_vpl011_uart_node(const struct domain *d, void *fdt) return res; res = fdt_property_cell(fdt, "interrupt-parent", - GUEST_PHANDLE_GIC); + kinfo->phandle_gic); if ( res ) return res; @@ -1721,6 +1723,8 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) int addrcells, sizecells; int ret; + kinfo->phandle_gic = GUEST_PHANDLE_GIC; + addrcells = GUEST_ROOT_ADDRESS_CELLS; sizecells = GUEST_ROOT_SIZE_CELLS; @@ -1764,7 +1768,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) if ( ret ) goto err; - ret = make_gic_domU_node(d, kinfo->fdt); + ret = make_gic_domU_node(kinfo); if ( ret ) goto err; @@ -1776,7 +1780,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) { ret = -EINVAL; #ifdef CONFIG_SBSA_VUART_CONSOLE - ret = make_vpl011_uart_node(d, kinfo->fdt); + ret = make_vpl011_uart_node(kinfo); #endif if ( ret ) goto err; @@ -1808,6 +1812,7 @@ static int __init prepare_dtb_hwdom(struct domain *d, struct kernel_info *kinfo) ASSERT(dt_host && (dt_host->sibling == NULL)); + kinfo->phandle_gic = dt_interrupt_controller->phandle; fdt = device_tree_flattened; new_size = fdt_totalsize(fdt) + DOM0_FDT_EXTRA_SIZE; diff --git a/xen/include/asm-arm/kernel.h b/xen/include/asm-arm/kernel.h index 33f3e72b11..43fa87545e 100644 --- a/xen/include/asm-arm/kernel.h +++ b/xen/include/asm-arm/kernel.h @@ -36,6 +36,9 @@ struct kernel_info { /* Enable pl011 emulation */ bool vpl011; + /* GIC phandle */ + uint32_t phandle_gic; + /* loader to use for this kernel */ void (*load)(struct kernel_info *info); /* loader specific state */