From nobody Thu Oct 30 22:39:45 2025 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; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1753374213; cv=none; d=zohomail.com; s=zohoarc; b=XT1NzuS4K914PsLtxGCYpaq8HUkHT1g+fUZlKaoWdz/RwjAAtBEryj67flHBWEOVbAj1p72hpxrxR2n19TUmFIo1L0YA3SzQkamGVZfT23Kn2XhVYaT6gp6Vis6EPeSqPjgvV+zNcl+myRqbbd5yuBigCPCFKgLM+V20+shN2Cw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753374213; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WUNEVSr3ncvwUF6ggoaVWELN0XIMn2xF+8CSNt91kWI=; b=gyHQ3HZ6gn/qa9f8x/PTgF5r3fyv+sWMg2v7vhV467Ip43+1qm9Y2lEIhCUpp762CseEWh6AWrD1gbfydnfVNLEHslKV+fXvO5yfzXH4kuLDwYEWM6X2f63HnotZfYSDklK1IXggsjkeFdykmsqmm4zZ37/XAeqm37Q7sEXQYrc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1753374213349268.8811569252656; Thu, 24 Jul 2025 09:23:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1056343.1424575 (Exim 4.92) (envelope-from ) id 1ueyiy-00087d-HM; Thu, 24 Jul 2025 16:23:16 +0000 Received: by outflank-mailman (output) from mailman id 1056343.1424575; Thu, 24 Jul 2025 16:23:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ueyiy-00087V-Dy; Thu, 24 Jul 2025 16:23:16 +0000 Received: by outflank-mailman (input) for mailman id 1056343; Thu, 24 Jul 2025 16:23:15 +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 1ueyix-0007fi-2E for xen-devel@lists.xenproject.org; Thu, 24 Jul 2025 16:23:15 +0000 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [2a00:1450:4864:20::334]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7fc9c920-68aa-11f0-a31e-13f23c93f187; Thu, 24 Jul 2025 18:23:14 +0200 (CEST) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-45629703011so8890285e9.0 for ; Thu, 24 Jul 2025 09:23:14 -0700 (PDT) Received: from localhost.localdomain (host-195-149-20-212.as13285.net. [195.149.20.212]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b76fcc2bc8sm2615965f8f.72.2025.07.24.09.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 09:23:13 -0700 (PDT) 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: 7fc9c920-68aa-11f0-a31e-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1753374194; x=1753978994; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WUNEVSr3ncvwUF6ggoaVWELN0XIMn2xF+8CSNt91kWI=; b=UVDDL3qeKba8E5Tc27rUTFrs9550jE74zvFk7quAXIE7HGgsUaCZL0Z2/PGmHpPRgA Ps5UPBv/p/9wgNf2U7j/g1Hf9d9/Ycku0gzWPGRJzIdCCmmwyrQxnMNkCt2grBy15kvv f+2yCip3xM+mztYy4ia+FGIcWGfEewtdrIqTY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753374194; x=1753978994; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WUNEVSr3ncvwUF6ggoaVWELN0XIMn2xF+8CSNt91kWI=; b=Wg1XFxl2JV2+Xl37EzUn0wlQy0NEJefR3uq2Xp/WUb/4vGuyq8D+RJkvR07SqJPEOG t0RR7CpVVyMc5mPYgYxBTQYDlauPx6lLvTf2Bt9/a0/O0GzVdGLKY6lu32PI+M7rQdNd li2zSymS9koq6NSfLpGU7tNJYBSvlDSV70yD4YOH1jYlL2ivycGq55SrxeUAsIeaucel 0SGBYFKxo5DkF2SlTBmHeK03zMJKwxWvWkqz89BoM6O8D5rEFx2det1P1r1CVMLc3vSD OAUI47c5QDqyKXqbYRK2n2Rz1/PGE1p/SwaBEyigynyqUnlmhsZF5HfY8Ii1Gm5rPFzO ue5g== X-Gm-Message-State: AOJu0YyNMLF4COl+48EjyIZteVhPb9sguXSR8yHGTCjYX4LUC0wJsEPc 8rXqEW3JWXmFb0gkW5iPiDDN3QS61/pvjxZWYzf2S/n/p2/Me/JPupVYTGfpQ8uBxlqqY22sQu0 fGrBewE/cBw== X-Gm-Gg: ASbGncsLB+AjOEdngxJF3EhN0tPrCg9Mo6cH7EE58+RpU2pXH5bbn6yH+5kspL3JpFY VlrJ33WG03iS+IWBOq/A1uzk0Gg6NPKI5LgrZ2joxeatA5XSCnaXc7tYrjWbAWGyJAMTrgiiCOF 30uAMEt0C9xvPZ9BCa/FyksQqmppduAH7DJOqSeMErUP1CKAJvON4jDmeuCdIyPBN/qir3Jb7Uq rSIbNzwFy9OuTXOA39wg/7qfx+qUvcJi7r02Gf5BxpydyJoCdgeEm/uvtrGDB2Z0HGq5EQ+VDwx GKCJ3tEIVQbpzXZlvMovsauZ0LnxARU3iZonZxUTxC0ZIiI1z0fyifINUv4zreBHUMdIKg4TVsc WZIuqA9dXfm5Zf9x4favcE6FGXv6GDyAh3hFwSMv0LKF1+ezUzxHypqsoiwFIWxJF+E9n7t9mvj kK X-Google-Smtp-Source: AGHT+IETg+5zCDMSNlJU5qdzPhpVUm7Wxk3S3oTLmiE/cjvepU7na87Pjkr8kOByV4nXRahlrEt+Lw== X-Received: by 2002:a05:600c:198b:b0:453:5c30:a1fd with SMTP id 5b1f17b1804b1-45868c9d23amr73249835e9.8.1753374193796; Thu, 24 Jul 2025 09:23:13 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Carlo Nonato , Marco Solieri Subject: [PATCH 3/4] xen/cache-col: Fix initialisation of domain colouring information Date: Thu, 24 Jul 2025 17:23:05 +0100 Message-Id: <20250724162306.2978741-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250724162306.2978741-1-andrew.cooper3@citrix.com> References: <20250724162306.2978741-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1753374213738116600 Right now, domains start with no colouring information and depend on a XEN_DOMCTL_set_llc_colors(nr=3D0) hypercall in order to get default colours. This in turn forces the toolstack to make a hypercall for all VMs even those without colouring configured, and to ignore errors if Xen doesn't have colouring active. Introduce domain_llc_coloring_init(), replacing domain_set_default_colors(), and call it during the trivial initialisation in domain_create(). Leave two comments explaining the positioning. The -EEXISTs condition in domain_set_llc_colors() needs adjusting as a consequence, but that's easy enough to keep working as before. Fixes: 6cdea3444eaf ("xen/arm: add Dom0 cache coloring support") Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Anthony PERARD CC: Michal Orzel CC: Jan Beulich CC: Julien Grall CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Carlo Nonato CC: Marco Solieri --- xen/common/domain.c | 6 ++++++ xen/common/llc-coloring.c | 33 ++++++++++++++------------------- xen/include/xen/llc-coloring.h | 2 ++ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 4f79ba39878c..28c2cc78cd88 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -878,6 +878,12 @@ struct domain *domain_create(domid_t domid, rwlock_init(&d->pci_lock); #endif =20 + /* + * Doesn't allocate memory itself, but does set up data relevant for + * memory allocations. + */ + domain_llc_coloring_init(d); + /* All error paths can depend on the above setup. */ =20 /* diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c index ea3e0ca07017..77a54beed1bf 100644 --- a/xen/common/llc-coloring.c +++ b/xen/common/llc-coloring.c @@ -230,24 +230,12 @@ void domain_dump_llc_colors(const struct domain *d) print_colors(d->llc_colors, d->num_llc_colors); } =20 -static void domain_set_default_colors(struct domain *d) -{ - printk(XENLOG_WARNING - "LLC color config not found for %pd, using all colors\n", d); - - d->llc_colors =3D default_colors; - d->num_llc_colors =3D max_nr_colors; -} - int __init dom0_set_llc_colors(struct domain *d) { typeof(*dom0_colors) *colors; =20 if ( !dom0_num_colors ) - { - domain_set_default_colors(d); return 0; - } =20 if ( (dom0_num_colors > max_nr_colors) || !check_colors(dom0_colors, dom0_num_colors) ) @@ -272,14 +260,11 @@ int domain_set_llc_colors(struct domain *d, { unsigned int *colors; =20 - if ( d->num_llc_colors ) + if ( d->llc_colors !=3D default_colors ) return -EEXIST; =20 if ( !config->num_llc_colors ) - { - domain_set_default_colors(d); return 0; - } =20 if ( config->num_llc_colors > max_nr_colors ) return -EINVAL; @@ -307,6 +292,19 @@ int domain_set_llc_colors(struct domain *d, return 0; } =20 +void domain_llc_coloring_init(struct domain *d) +{ + if ( !llc_coloring_enabled ) + return; + + /* + * Any change to this logic needs to consider the position of our call= in + * domain_create(). + */ + d->llc_colors =3D default_colors; + d->num_llc_colors =3D max_nr_colors; +} + void domain_llc_coloring_free(struct domain *d) { d->num_llc_colors =3D 0; @@ -321,10 +319,7 @@ int __init domain_set_llc_colors_from_str(struct domai= n *d, const char *str) unsigned int *colors, num_colors; =20 if ( !str ) - { - domain_set_default_colors(d); return 0; - } =20 colors =3D xmalloc_array(unsigned int, max_nr_colors); if ( !colors ) diff --git a/xen/include/xen/llc-coloring.h b/xen/include/xen/llc-coloring.h index 45f250f9f39d..94dd22e949e7 100644 --- a/xen/include/xen/llc-coloring.h +++ b/xen/include/xen/llc-coloring.h @@ -21,6 +21,7 @@ extern bool llc_coloring_enabled; void llc_coloring_init(void); void dump_llc_coloring_info(void); void domain_dump_llc_colors(const struct domain *d); +void domain_llc_coloring_init(struct domain *d); void domain_llc_coloring_free(struct domain *d); #else #define llc_coloring_enabled false @@ -28,6 +29,7 @@ void domain_llc_coloring_free(struct domain *d); static inline void llc_coloring_init(void) {} static inline void dump_llc_coloring_info(void) {} static inline void domain_dump_llc_colors(const struct domain *d) {} +static inline void domain_llc_coloring_init(struct domain *d) {} static inline void domain_llc_coloring_free(struct domain *d) {} #endif =20 --=20 2.39.5