From nobody Tue Feb 10 01:35:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1646417843645575.6514630219825; Fri, 4 Mar 2022 10:17:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.284422.483757 (Exim 4.92) (envelope-from ) id 1nQCUC-0004Hv-5a; Fri, 04 Mar 2022 18:17:04 +0000 Received: by outflank-mailman (output) from mailman id 284422.483757; Fri, 04 Mar 2022 18:17:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nQCUB-0004Df-IL; Fri, 04 Mar 2022 18:17:03 +0000 Received: by outflank-mailman (input) for mailman id 284422; Fri, 04 Mar 2022 17:48:04 +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 1nQC28-0005R5-LJ for xen-devel@lists.xenproject.org; Fri, 04 Mar 2022 17:48:04 +0000 Received: from radon.xt3.it (radon.xt3.it [2a01:4f8:190:4055::2]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3b6e7c23-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 1nQC23-0008R5-Fw; Fri, 04 Mar 2022 18:47:59 +0100 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 3b6e7c23-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 09/36] xen/arch: add default colors selection function Date: Fri, 4 Mar 2022 18:46:34 +0100 Message-Id: <20220304174701.1453977-10-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 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1646417844595100004 Content-Type: text/plain; charset="utf-8" From: Luca Miccio When cache coloring support is enabled, a color assignment is needed for every domain. Introduce a function computing a default configuration with a safe and common value -- the dom0 color selection. Do not access directly the array of color indices of dom0. Instead make use of the dom0 color configuration as a bitmask. Add a helper function that converts the color configuration bitmask into the indices array. Signed-off-by: Luca Miccio Signed-off-by: Marco Solieri --- xen/arch/arm/coloring.c | 36 +++++++++++++++++++++++++++++ xen/arch/arm/include/asm/coloring.h | 7 ++++++ 2 files changed, 43 insertions(+) diff --git a/xen/arch/arm/coloring.c b/xen/arch/arm/coloring.c index af75b536a7..f6e6d09477 100644 --- a/xen/arch/arm/coloring.c +++ b/xen/arch/arm/coloring.c @@ -143,6 +143,42 @@ static __init uint64_t calculate_addr_col_mask(uint64_= t llc_way_size) return addr_col_mask; } =20 +static int copy_mask_to_list( + uint32_t *col_mask, uint32_t *col_list, uint64_t col_num) +{ + unsigned int i, k, c; + + if ( !col_list ) + return -EINVAL; + + for ( i =3D 0, k =3D 0; i < MAX_COLORS_CELLS; i++ ) + for ( c =3D 0; k < col_num && c < 32; c++ ) + if ( col_mask[i] & (1 << (c + (i*32))) ) + col_list[k++] =3D c + (i * 32); + + return 0; +} + +uint32_t *setup_default_colors(uint32_t *col_num) +{ + uint32_t *col_list; + + if ( dom0_col_num ) + { + *col_num =3D dom0_col_num; + col_list =3D xzalloc_array(uint32_t, dom0_col_num); + if ( !col_list ) + { + printk(XENLOG_ERR "setup_default_colors: Alloc failed\n"); + return NULL; + } + copy_mask_to_list(dom0_col_mask, col_list, dom0_col_num); + return col_list; + } + + return NULL; +} + 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 70e1dbd09b..8f24acf082 100644 --- a/xen/arch/arm/include/asm/coloring.h +++ b/xen/arch/arm/include/asm/coloring.h @@ -27,6 +27,13 @@ =20 #ifdef CONFIG_COLORING bool __init coloring_init(void); + +/* + * 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 + * color configuration. + */ +uint32_t *setup_default_colors(uint32_t *col_num); #else /* !CONFIG_COLORING */ static inline bool __init coloring_init(void) { --=20 2.30.2