From patchwork Fri Mar 4 17:46:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Solieri X-Patchwork-Id: 12769745 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 154A5C433EF for ; Fri, 4 Mar 2022 18:17:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.284425.483769 (Exim 4.92) (envelope-from ) id 1nQCUD-0004ZK-RS; Fri, 04 Mar 2022 18:17:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 284425.483769; Fri, 04 Mar 2022 18:17:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nQCUC-0004Vu-Mq; Fri, 04 Mar 2022 18:17:04 +0000 Received: by outflank-mailman (input) for mailman id 284425; Fri, 04 Mar 2022 17:48:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nQC29-0005R5-LP for xen-devel@lists.xenproject.org; Fri, 04 Mar 2022 17:48:05 +0000 Received: from radon.xt3.it (radon.xt3.it [2a01:4f8:190:4055::2]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3bd73a6b-9be3-11ec-8539-5f4723681683; Fri, 04 Mar 2022 18:48:00 +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 1nQC24-0008Rc-7e; Fri, 04 Mar 2022 18:48:00 +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: 3bd73a6b-9be3-11ec-8539-5f4723681683 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 10/36] xen/arch: check color selection function Date: Fri, 4 Mar 2022 18:46:35 +0100 Message-Id: <20220304174701.1453977-11-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 Dom0 color configuration is parsed in the Xen command line. Add an helper function to check the user selection. If no configuration is provided by the user, all the available colors supported by the hardware will be assigned to dom0. Signed-off-by: Luca Miccio Signed-off-by: Marco Solieri Tested-by: Henry Wang --- xen/arch/arm/coloring.c | 17 +++++++++++++++++ xen/arch/arm/include/asm/coloring.h | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/xen/arch/arm/coloring.c b/xen/arch/arm/coloring.c index f6e6d09477..382d558021 100644 --- a/xen/arch/arm/coloring.c +++ b/xen/arch/arm/coloring.c @@ -179,6 +179,23 @@ uint32_t *setup_default_colors(uint32_t *col_num) return NULL; } +bool check_domain_colors(struct domain *d) +{ + int i; + bool ret = false; + + if ( !d ) + return ret; + + if ( d->max_colors > max_col_num ) + return ret; + + for ( i = 0; i < d->max_colors; i++ ) + ret |= (d->colors[i] > (max_col_num - 1)); + + return !ret; +} + bool __init coloring_init(void) { int i; diff --git a/xen/arch/arm/include/asm/coloring.h b/xen/arch/arm/include/asm/coloring.h index 8f24acf082..fdd46448d7 100644 --- a/xen/arch/arm/include/asm/coloring.h +++ b/xen/arch/arm/include/asm/coloring.h @@ -26,8 +26,16 @@ #define MAX_COLORS_CELLS 4 #ifdef CONFIG_COLORING +#include + bool __init coloring_init(void); +/* + * Check colors of a given domain. + * Return true if check passed, false otherwise. + */ +bool check_domain_colors(struct domain *d); + /* * Return an array with default colors selection and store the number of * colors in @param col_num. The array selection will be equal to the dom0