From patchwork Fri Mar 4 17:46:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Solieri X-Patchwork-Id: 12769741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5906CC4332F for ; Fri, 4 Mar 2022 18:17:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.284419.483738 (Exim 4.92) (envelope-from ) id 1nQCUA-0003fI-2Q; Fri, 04 Mar 2022 18:17:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 284419.483738; Fri, 04 Mar 2022 18:17:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nQCU9-0003by-1h; Fri, 04 Mar 2022 18:17:01 +0000 Received: by outflank-mailman (input) for mailman id 284419; Fri, 04 Mar 2022 17:48:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nQC27-0005R4-GZ for xen-devel@lists.xenproject.org; Fri, 04 Mar 2022 17:48:03 +0000 Received: from radon.xt3.it (radon.xt3.it [2a01:4f8:190:4055::2]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3ced96da-9be3-11ec-8eba-a37418f5ba1a; Fri, 04 Mar 2022 18:48:02 +0100 (CET) Received: from nb2assolieri.mat.unimo.it ([155.185.4.56] helo=localhost) by radon.xt3.it with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1nQC25-0008Sl-Vu; Fri, 04 Mar 2022 18:48:02 +0100 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3ced96da-9be3-11ec-8eba-a37418f5ba1a From: Marco Solieri To: xen-devel@lists.xenproject.org Cc: Marco Solieri , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Marco Solieri , Andrea Bastoni , Luca Miccio Subject: [PATCH 12/36] xen/arm: initialize cache coloring data for Dom0/U Date: Fri, 4 Mar 2022 18:46:37 +0100 Message-Id: <20220304174701.1453977-13-marco.solieri@minervasys.tech> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220304174701.1453977-1-marco.solieri@minervasys.tech> References: <20220304174701.1453977-1-marco.solieri@minervasys.tech> MIME-Version: 1.0 From: Luca Miccio Initialize cache coloring configuration during domain creation. If no colors assignment is provided by the user, use the default one. The default configuration is the one assigned to Dom0. The latter is configured as a standard domain with default configuration. Signed-off-by: Luca Miccio Signed-off-by: Marco Solieri --- xen/arch/arm/domain.c | 53 +++++++++++++++++++++++++++++++++++++ xen/arch/arm/domain_build.c | 5 +++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 8110c1df86..33471b3c58 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "vpci.h" #include "vuart.h" @@ -782,6 +783,58 @@ int arch_domain_create(struct domain *d, if ( (rc = domain_vpci_init(d)) != 0 ) goto fail; + d->max_colors = 0; +#ifdef CONFIG_COLORING + /* Setup domain colors */ + if ( !config->arch.colors.max_colors ) + { + if ( !is_hardware_domain(d) ) + printk(XENLOG_INFO "Color configuration not found for dom%u, using default\n", + d->domain_id); + d->colors = setup_default_colors(&d->max_colors); + if ( !d->colors ) + { + rc = -ENOMEM; + printk(XENLOG_ERR "Color array allocation failed for dom%u\n", + d->domain_id); + goto fail; + } + } + else + { + int i, k; + + d->colors = xzalloc_array(uint32_t, config->arch.colors.max_colors); + if ( !d->colors ) + { + rc = -ENOMEM; + printk(XENLOG_ERR "Failed to alloc colors for dom%u\n", + d->domain_id); + goto fail; + } + + d->max_colors = config->arch.colors.max_colors; + for ( i = 0, k = 0; + k < d->max_colors && i < sizeof(config->arch.colors.colors) * 8; + i++ ) + { + if ( config->arch.colors.colors[i / 32] & (1 << (i % 32)) ) + d->colors[k++] = i; + } + } + + printk("Dom%u colors: [ ", d->domain_id); + for ( int i = 0; i < d->max_colors; i++ ) + printk("%u ", d->colors[i]); + printk("]\n"); + + if ( !check_domain_colors(d) ) + { + rc = -EINVAL; + printk(XENLOG_ERR "Failed to check colors for dom%u\n", d->domain_id); + goto fail; + } +#endif return 0; fail: diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 8be01678de..9630d00066 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3344,7 +3344,10 @@ void __init create_dom0(void) printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded.\n"); dom0_cfg.arch.tee_type = tee_get_type(); dom0_cfg.max_vcpus = dom0_max_vcpus(); - +#ifdef CONFIG_COLORING + /* Colors are set after domain_create */ + dom0_cfg.arch.colors.max_colors = 0; +#endif if ( iommu_enabled ) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;