From patchwork Mon Jan 29 17:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536085 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 14EB1C47DB3 for ; Mon, 29 Jan 2024 17:19:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673061.1047216 (Exim 4.92) (envelope-from ) id 1rUVI1-0005w0-M5; Mon, 29 Jan 2024 17:19:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673061.1047216; Mon, 29 Jan 2024 17:19:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI1-0005vt-II; Mon, 29 Jan 2024 17:19:21 +0000 Received: by outflank-mailman (input) for mailman id 673061; Mon, 29 Jan 2024 17:19:20 +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 1rUVI0-0005vY-EV for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:20 +0000 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [2a00:1450:4864:20::534]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8903ff3e-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:18 +0100 (CET) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-55eb1f9d1f0so3956913a12.0 for ; Mon, 29 Jan 2024 09:19:18 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:17 -0800 (PST) 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: 8903ff3e-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548758; x=1707153558; 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=+hv5wbDw5zgCt9ccmVowLGqtempCv7CEDV12eNerpQk=; b=d41rw/jC27kx6CDnGc4OsdN8fF1X8tt9xuRirbD289tr374hiZcZyUShOx9RQ/9DHC OPxxc8wLoiNBASPcT1rvJk7Vj5oH6Sxl/VEvdg6e2UMHblZwLDb6zbpDVXvWEc/0iRWT NuGB59aG70XcKn80elQqduhlCkgBfrNzGvLYvt+lA+XPxn2spOXXySeD36yo/hIooVUU rmTnysPv83OhgzzTphJODIuLFbMsWny2iKNo5hH2N2Luvgqe/1Hxlfhl1jmzZUaRQHYT 7RNVUvlYZPbtzI3naqU1xqJXApTEhfm68G0lpXm6ybnsJyQn1c7SycgI4msbFqPrqzYY MAVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548758; x=1707153558; 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=+hv5wbDw5zgCt9ccmVowLGqtempCv7CEDV12eNerpQk=; b=neKxYdVTELuQVs4bUczDT0HnyogZb4mjufOcWY0gKrCCFY7LzboP2X42k7eCyyrHN6 XWotXNZtBAKwL6aH5HD6vJPi2En5rEO2pHEUQoGWU+7UjhgI2nvj9JL6qk3dEPBD18qb uEy2CgbVgwbJSHRbvzbXH8VYYfZq0GF5T/QzKJtmPNpbXkctEAgJD7L4lL5PTd8Envaz /wDCXdkrTDCfThTmFpkaXB6e91bIqiSpGz/0EJ4N0dtYPVXI8AQP3gN4Jam/PfO9pSxx vbr8JLe9ADvCws//ZcAlzMvrk6vSnNdP6/mPghtc0kzIx1M2BdqOP9fwNNEebfPMH4B1 s0xQ== X-Gm-Message-State: AOJu0YwLdIwbnoyHLtC3Du5adVnc56qy87QCWePxnTnthu9PpKnzGEFF Zeqz/MffIZgeZPO1VPMgv3XB8UZLNZxf6bnVNTpDODd3t07TdJr5t9u4YpOYVBwqvA/k+hhPCha UNXg= X-Google-Smtp-Source: AGHT+IEXJpomaco9S1o1pO/0EpXOhqKzjixYigXXi2qXJK2rcOISoW4ZekLLP4YaXURpOECuZYCm4w== X-Received: by 2002:aa7:c312:0:b0:55e:eb6e:ff51 with SMTP id l18-20020aa7c312000000b0055eeb6eff51mr3877944edq.12.1706548757791; Mon, 29 Jan 2024 09:19:17 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Marco Solieri Subject: [PATCH v6 01/15] xen/common: add cache coloring common code Date: Mon, 29 Jan 2024 18:17:57 +0100 Message-Id: <20240129171811.21382-2-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Last Level Cache (LLC) coloring allows to partition the cache in smaller chunks called cache colors. Since not all architectures can actually implement it, add a HAS_LLC_COLORING Kconfig and put other options under xen/arch. LLC colors are a property of the domain, so the domain struct has to be extended. Based on original work from: Luca Miccio Signed-off-by: Carlo Nonato Signed-off-by: Marco Solieri --- v6: - moved almost all code in common - moved documentation in this patch - reintroduced range for CONFIG_NR_LLC_COLORS - reintroduced some stub functions to reduce the number of checks on llc_coloring_enabled - moved domain_llc_coloring_free() in same patch where allocation happens - turned "d->llc_colors" to pointer-to-const - llc_coloring_init() now returns void and panics if errors are found v5: - used - instead of _ for filenames - removed domain_create_llc_colored() - removed stub functions - coloring domain fields are now #ifdef protected v4: - Kconfig options moved to xen/arch - removed range for CONFIG_NR_LLC_COLORS - added "llc_coloring_enabled" global to later implement the boot-time switch - added domain_create_llc_colored() to be able to pass colors - added is_domain_llc_colored() macro --- docs/misc/cache-coloring.rst | 87 +++++++++++++++++++++++++++++++ docs/misc/xen-command-line.pandoc | 27 ++++++++++ xen/arch/Kconfig | 17 ++++++ xen/common/Kconfig | 3 ++ xen/common/Makefile | 1 + xen/common/keyhandler.c | 3 ++ xen/common/llc-coloring.c | 87 +++++++++++++++++++++++++++++++ xen/include/xen/llc-coloring.h | 38 ++++++++++++++ xen/include/xen/sched.h | 5 ++ 9 files changed, 268 insertions(+) create mode 100644 docs/misc/cache-coloring.rst create mode 100644 xen/common/llc-coloring.c create mode 100644 xen/include/xen/llc-coloring.h diff --git a/docs/misc/cache-coloring.rst b/docs/misc/cache-coloring.rst new file mode 100644 index 0000000000..9fe01e99e1 --- /dev/null +++ b/docs/misc/cache-coloring.rst @@ -0,0 +1,87 @@ +Xen cache coloring user guide +============================= + +The cache coloring support in Xen allows to reserve Last Level Cache (LLC) +partitions for Dom0, DomUs and Xen itself. Currently only ARM64 is supported. + +To compile LLC coloring support set ``CONFIG_LLC_COLORING=y``. + +If needed, change the maximum number of colors with +``CONFIG_NR_LLC_COLORS=``. + +Compile Xen and the toolstack and then configure it via +`Command line parameters`_. + +Background +********** + +Cache hierarchy of a modern multi-core CPU typically has first levels dedicated +to each core (hence using multiple cache units), while the last level is shared +among all of them. Such configuration implies that memory operations on one +core (e.g. running a DomU) are able to generate interference on another core +(e.g .hosting another DomU). Cache coloring allows eliminating this +mutual interference, and thus guaranteeing higher and more predictable +performances for memory accesses. +The key concept underlying cache coloring is a fragmentation of the memory +space into a set of sub-spaces called colors that are mapped to disjoint cache +partitions. Technically, the whole memory space is first divided into a number +of subsequent regions. Then each region is in turn divided into a number of +subsequent sub-colors. The generic i-th color is then obtained by all the +i-th sub-colors in each region. + +:: + + Region j Region j+1 + ..................... ............ + . . . + . . + _ _ _______________ _ _____________________ _ _ + | | | | | | | + | c_0 | c_1 | | c_n | c_0 | c_1 | + _ _ _|_____|_____|_ _ _|_____|_____|_____|_ _ _ + : : + : :... ... . + : color 0 + :........................... ... . + : + . . ..................................: + +There are two pragmatic lesson to be learnt. + +1. If one wants to avoid cache interference between two domains, different + colors needs to be used for their memory. + +2. Color assignment must privilege contiguity in the partitioning. E.g., + assigning colors (0,1) to domain I and (2,3) to domain J is better than + assigning colors (0,2) to I and (1,3) to J. + +How to compute the number of colors +*********************************** + +To compute the number of available colors for a specific platform, the size of +an LLC way and the page size used by Xen must be known. The first parameter can +be found in the processor manual or can be also computed dividing the total +cache size by the number of its ways. The second parameter is the minimum +amount of memory that can be mapped by the hypervisor, thus dividing the way +size by the page size, the number of total cache partitions is found. So for +example, an Arm Cortex-A53 with a 16-ways associative 1 MiB LLC, can isolate up +to 16 colors when pages are 4 KiB in size. + +Cache layout is probed automatically by looking at the CLIDR_EL1 arm register. +This means that other system caches that aren't visible there, are ignored. +The possibility of manually setting the way size is left to the user to overcome +failing situations or for debugging/testing purposes. See +`Command line parameters`_ for more information on that. + +Command line parameters +*********************** + +More specific documentation is available at `docs/misc/xen-command-line.pandoc`. + ++----------------------+-------------------------------+ +| **Parameter** | **Description** | ++----------------------+-------------------------------+ +| ``llc-coloring`` | enable coloring at runtime | ++----------------------+-------------------------------+ +| ``llc-way-size`` | set the LLC way size | ++----------------------+-------------------------------+ diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 8e65f8bd18..11f9f209d1 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1713,6 +1713,33 @@ This option is intended for debugging purposes only. Enable MSR_DEBUGCTL.LBR in hypervisor context to be able to dump the Last Interrupt/Exception To/From record with other registers. +### llc-coloring +> `= ` + +> Default: `false` + +Flag to enable or disable LLC coloring support at runtime. This options is +available only when `CONFIG_LLC_COLORING` is enabled. See the general +cache coloring documentation for more info. + +### llc-way-size +> `= ` + +> Default: `Obtained from the hardware` + +Specify the way size of the Last Level Cache. This options is available only +when `CONFIG_LLC_COLORING` is enabled. It is an optional, expert-only parameter +and it is used to calculate the number of available LLC colors on the platform. +It can be obtained by dividing the total LLC size by the number of its +associative ways. +By default, the value is automatically computed by probing the hardware, but in +case of specific needs, it can be manually set. Those include failing probing +and debugging/testing purposes so that it's possibile to emulate platforms with +different number of supported colors. +An important detail to highlight is that the current implementation of the +cache coloring technique requires the number of colors to be a power of 2, and +consequently, also the LLC way size must be so. + ### lock-depth-size > `= ` diff --git a/xen/arch/Kconfig b/xen/arch/Kconfig index 67ba38f32f..c1157bcbcb 100644 --- a/xen/arch/Kconfig +++ b/xen/arch/Kconfig @@ -31,3 +31,20 @@ config NR_NUMA_NODES associated with multiple-nodes management. It is the upper bound of the number of NUMA nodes that the scheduler, memory allocation and other NUMA-aware components can handle. + +config LLC_COLORING + bool "Last Level Cache (LLC) coloring" if EXPERT + depends on HAS_LLC_COLORING + +config NR_LLC_COLORS + int "Maximum number of LLC colors" + range 2 1024 + default 128 + depends on LLC_COLORING + help + Controls the build-time size of various arrays associated with LLC + coloring. Refer to cache coloring documentation for how to compute the + number of colors supported by the platform. This is only an upper + bound. The runtime value is autocomputed or manually set via cmdline. + The default value corresponds to an 8 MiB 16-ways LLC, which should be + more than what needed in the general case. diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 310ad4229c..e383f09d97 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -71,6 +71,9 @@ config HAS_IOPORTS config HAS_KEXEC bool +config HAS_LLC_COLORING + bool + config HAS_PMAP bool diff --git a/xen/common/Makefile b/xen/common/Makefile index 69d6aa626c..409cc53e2a 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -24,6 +24,7 @@ obj-y += keyhandler.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC) += kimage.o obj-$(CONFIG_LIVEPATCH) += livepatch.o livepatch_elf.o +obj-$(CONFIG_LLC_COLORING) += llc-coloring.o obj-$(CONFIG_MEM_ACCESS) += mem_access.o obj-y += memory.o obj-y += multicall.o diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index 99a2d72a02..8d90b613f7 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -307,6 +308,8 @@ static void cf_check dump_domains(unsigned char key) arch_dump_domain_info(d); + domain_dump_llc_colors(d); + rangeset_domain_printk(d); dump_pageframe_info(d); diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c new file mode 100644 index 0000000000..10729e70c1 --- /dev/null +++ b/xen/common/llc-coloring.c @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Last Level Cache (LLC) coloring common code + * + * Copyright (C) 2022 Xilinx Inc. + */ +#include +#include +#include + +bool __ro_after_init llc_coloring_enabled; +boolean_param("llc-coloring", llc_coloring_enabled); + +/* Size of an LLC way */ +static unsigned int __ro_after_init llc_way_size; +size_param("llc-way-size", llc_way_size); +/* Number of colors available in the LLC */ +static unsigned int __ro_after_init max_nr_colors = CONFIG_NR_LLC_COLORS; + +static void print_colors(const unsigned int *colors, unsigned int num_colors) +{ + unsigned int i; + + printk("{ "); + for ( i = 0; i < num_colors; i++ ) { + unsigned int start = colors[i], end = colors[i]; + + printk("%u", start); + + for ( ; + i < num_colors - 1 && colors[i] + 1 == colors[i + 1]; + i++, end++ ); + + if ( start != end ) + printk("-%u", end); + + if ( i < num_colors - 1 ) + printk(", "); + } + printk(" }\n"); +} + +static void dump_coloring_info(unsigned char key) +{ + printk("'%c' pressed -> dumping LLC coloring general info\n", key); + printk("LLC way size: %u KiB\n", llc_way_size >> 10); + printk("Number of LLC colors supported: %u\n", max_nr_colors); +} + +void __init llc_coloring_init(void) +{ + if ( !llc_way_size && !(llc_way_size = get_llc_way_size()) ) + panic("Probed LLC coloring way size is 0 and no custom value found\n"); + + /* + * The maximum number of colors must be a power of 2 in order to correctly + * map them to bits of an address, so also the LLC way size must be so. + */ + if ( llc_way_size & (llc_way_size - 1) ) + panic("LLC coloring way size (%u) isn't a power of 2\n", llc_way_size); + + max_nr_colors = llc_way_size >> PAGE_SHIFT; + + if ( max_nr_colors < 2 || max_nr_colors > CONFIG_NR_LLC_COLORS ) + panic("Number of LLC colors (%u) not in range [2, %u]\n", + max_nr_colors, CONFIG_NR_LLC_COLORS); + + register_keyhandler('K', dump_coloring_info, "dump LLC coloring info", 1); + + arch_llc_coloring_init(); +} + +void domain_dump_llc_colors(const struct domain *d) +{ + printk("Domain %pd has %u LLC colors: ", d, d->num_llc_colors); + print_colors(d->llc_colors, d->num_llc_colors); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/llc-coloring.h b/xen/include/xen/llc-coloring.h new file mode 100644 index 0000000000..5e12eb426f --- /dev/null +++ b/xen/include/xen/llc-coloring.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Last Level Cache (LLC) coloring common header + * + * Copyright (C) 2022 Xilinx Inc. + */ +#ifndef __COLORING_H__ +#define __COLORING_H__ + +#include +#include + +#ifdef CONFIG_LLC_COLORING +extern bool llc_coloring_enabled; + +void llc_coloring_init(void); +void domain_dump_llc_colors(const struct domain *d); +#else +#define llc_coloring_enabled false + +static inline void llc_coloring_init(void) {} +static inline void domain_dump_llc_colors(const struct domain *d) {} +#endif + +unsigned int get_llc_way_size(void); +void arch_llc_coloring_init(void); + +#endif /* __COLORING_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 9da91e0e62..8df0f29335 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -626,6 +626,11 @@ struct domain /* Holding CDF_* constant. Internal flags for domain creation. */ unsigned int cdf; + +#ifdef CONFIG_LLC_COLORING + unsigned const int *llc_colors; + unsigned int num_llc_colors; +#endif }; static inline struct page_list_head *page_to_list( From patchwork Mon Jan 29 17:17:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536096 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 D1AA0C48295 for ; Mon, 29 Jan 2024 17:19:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673063.1047228 (Exim 4.92) (envelope-from ) id 1rUVI2-00068T-Cn; Mon, 29 Jan 2024 17:19:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673063.1047228; Mon, 29 Jan 2024 17:19:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI2-00067g-9h; Mon, 29 Jan 2024 17:19:22 +0000 Received: by outflank-mailman (input) for mailman id 673063; Mon, 29 Jan 2024 17:19:21 +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 1rUVI1-0005vY-2g for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:21 +0000 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [2a00:1450:4864:20::229]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 897d3212-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:19 +0100 (CET) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2d04f3d9332so11475611fa.1 for ; Mon, 29 Jan 2024 09:19:19 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:18 -0800 (PST) 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: 897d3212-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548759; x=1707153559; 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=NWZWToXQ8ShJksi8sO6nrYFAeFvPtEgXsN4D6Ih4w4M=; b=N7h8ofh4vNcJvAuAl+GtpIGq/F0uLrwq4X0NlzMfyWrhzLxk8c4ci8hXN1XjTJeflE Lwbz7aaeCHkPqAkLZHzN//Zhqbj9Xd6yXjIaj9IB9RrKqWcFjqxyKdNvaczusK9bHpCY ZX6C4tFiSdMhIQd0mU7hg2TU4OxMxD0VzLqOIxgZua2jv2WoTW90ed/D6V+yDwJzUFtx LYz8OLznlSUaY7RR7h1VbaTv4zZDZm9SBffl30QJM9Mxf27cYm0CNjFXBHxJWR1DHTl7 V6Hwup6rfMVY/ag3UotIOxxnnUFhC/DywdHq5b7xUcSoIa4UxW7aKvMVobHv+ujZ02qI iPJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548759; x=1707153559; 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=NWZWToXQ8ShJksi8sO6nrYFAeFvPtEgXsN4D6Ih4w4M=; b=E8hC6j7NqWtOrTE/8FKpMczgFxbg1YRzZssUciYi09vu4Xm9zOs380RZtK30tjVKy1 /TfMPs/GuOhn1OWzoiTekaZ+yj8IEUg+ReJN581PsdQCrIJmc+SDiOdumQAoUnXpPpbk blkkBm4VlB4DcPZkAXN8pjsb8fqEu69ccz6/hC1GxIRPofuk15OC2gCJmy1c1Gs4Wve7 nTgno/bI+JSKvOyZwjNkmVFVx+DoYpFYLEbj+nhEkGWPQ+rE1JGozypU57PKiUV/VUQl FVJNCPpHFvPjw/h8vDGqIKJYBNfXmjb1IPOy30AAyleOsTeljQEAr3RrFl90ebQphV+3 UASw== X-Gm-Message-State: AOJu0Yw52lnhXeMM3RKqr/l4xM5IQ2i9cVMgfwfhofyX+xD7vGgS+Bfn 2+3LNXeMPnLJFNfpZYPZD+yUBEgm4oEwIec6jlW3yWYhbCDIefx4qq1cqOIKfmVyrjyON7OJ0rQ em1Y= X-Google-Smtp-Source: AGHT+IE3Mu8k13ywcg8aZZoB34Z++ujFBvsu5KpGB9UD0c/Rz5sLZvuBZ10GgtiPkDmZprzjT7rJ2Q== X-Received: by 2002:a2e:b705:0:b0:2cf:1c39:86eb with SMTP id j5-20020a2eb705000000b002cf1c3986ebmr4381850ljo.31.1706548758593; Mon, 29 Jan 2024 09:19:18 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Marco Solieri Subject: [PATCH v6 02/15] xen/arm: add initial support for LLC coloring on arm64 Date: Mon, 29 Jan 2024 18:17:58 +0100 Message-Id: <20240129171811.21382-3-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 LLC coloring needs to know the last level cache layout in order to make the best use of it. This can be probed by inspecting the CLIDR_EL1 register, so the Last Level is defined as the last level visible by this register. Note that this excludes system caches in some platforms. Static memory allocation and cache coloring are incompatible because static memory can't be guaranteed to use only colors assigned to the domain. Panic during DomUs creation when both are enabled. Based on original work from: Luca Miccio Signed-off-by: Carlo Nonato Signed-off-by: Marco Solieri --- v6: - get_llc_way_size() now checks for at least separate I/D caches v5: - used - instead of _ for filenames - moved static-mem check in this patch - moved dom0 colors parsing in next patch - moved color allocation and configuration in next patch - moved check_colors() in next patch - colors are now printed in short form v4: - added "llc-coloring" cmdline option for the boot-time switch - dom0 colors are now checked during domain init as for any other domain - fixed processor.h masks bit width - check for overflow in parse_color_config() - check_colors() now checks also that colors are sorted and unique --- docs/misc/cache-coloring.rst | 11 ++++ xen/arch/arm/Kconfig | 1 + xen/arch/arm/Makefile | 1 + xen/arch/arm/dom0less-build.c | 6 +++ xen/arch/arm/include/asm/processor.h | 16 ++++++ xen/arch/arm/llc-coloring.c | 75 ++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 3 ++ 7 files changed, 113 insertions(+) create mode 100644 xen/arch/arm/llc-coloring.c diff --git a/docs/misc/cache-coloring.rst b/docs/misc/cache-coloring.rst index 9fe01e99e1..0535b5c656 100644 --- a/docs/misc/cache-coloring.rst +++ b/docs/misc/cache-coloring.rst @@ -85,3 +85,14 @@ More specific documentation is available at `docs/misc/xen-command-line.pandoc`. +----------------------+-------------------------------+ | ``llc-way-size`` | set the LLC way size | +----------------------+-------------------------------+ + +Known issues and limitations +**************************** + +"xen,static-mem" isn't supported when coloring is enabled +######################################################### + +In the domain configuration, "xen,static-mem" allows memory to be statically +allocated to the domain. This isn't possible when LLC coloring is enabled, +because that memory can't be guaranteed to use only colors assigned to the +domain. diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 50e9bfae1a..55143f86a9 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -8,6 +8,7 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_LLC_COLORING config ARM def_bool y diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 33c677672f..c9a1cd298d 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_IOREQ_SERVER) += ioreq.o obj-y += irq.o obj-y += kernel.init.o obj-$(CONFIG_LIVEPATCH) += livepatch.o +obj-$(CONFIG_LLC_COLORING) += llc-coloring.o obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index fb63ec6fd1..1142f7f74a 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -879,7 +880,12 @@ void __init create_domUs(void) panic("No more domain IDs available\n"); if ( dt_find_property(node, "xen,static-mem", NULL) ) + { + if ( llc_coloring_enabled ) + panic("LLC coloring and static memory are incompatible\n"); + flags |= CDF_staticmem; + } if ( dt_property_read_bool(node, "direct-map") ) { diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/asm/processor.h index 8e02410465..336933ee62 100644 --- a/xen/arch/arm/include/asm/processor.h +++ b/xen/arch/arm/include/asm/processor.h @@ -18,6 +18,22 @@ #define CTR_IDC_SHIFT 28 #define CTR_DIC_SHIFT 29 +/* CCSIDR Current Cache Size ID Register */ +#define CCSIDR_LINESIZE_MASK _AC(0x7, ULL) +#define CCSIDR_NUMSETS_SHIFT 13 +#define CCSIDR_NUMSETS_MASK _AC(0x3fff, ULL) +#define CCSIDR_NUMSETS_SHIFT_FEAT_CCIDX 32 +#define CCSIDR_NUMSETS_MASK_FEAT_CCIDX _AC(0xffffff, ULL) + +/* CSSELR Cache Size Selection Register */ +#define CSSELR_LEVEL_MASK _AC(0x7, UL) +#define CSSELR_LEVEL_SHIFT 1 + +/* CLIDR Cache Level ID Register */ +#define CLIDR_CTYPEn_SHIFT(n) (3 * (n - 1)) +#define CLIDR_CTYPEn_MASK _AC(0x7, UL) +#define CLIDR_CTYPEn_LEVELS 7 + #define ICACHE_POLICY_VPIPT 0 #define ICACHE_POLICY_AIVIVT 1 #define ICACHE_POLICY_VIPT 2 diff --git a/xen/arch/arm/llc-coloring.c b/xen/arch/arm/llc-coloring.c new file mode 100644 index 0000000000..eee1e80e2d --- /dev/null +++ b/xen/arch/arm/llc-coloring.c @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Last Level Cache (LLC) coloring support for ARM + * + * Copyright (C) 2022 Xilinx Inc. + */ +#include +#include + +#include +#include + +/* Return the LLC way size by probing the hardware */ +unsigned int __init get_llc_way_size(void) +{ + register_t ccsidr_el1; + register_t clidr_el1 = READ_SYSREG(CLIDR_EL1); + register_t csselr_el1 = READ_SYSREG(CSSELR_EL1); + register_t id_aa64mmfr2_el1 = READ_SYSREG(ID_AA64MMFR2_EL1); + uint32_t ccsidr_numsets_shift = CCSIDR_NUMSETS_SHIFT; + uint32_t ccsidr_numsets_mask = CCSIDR_NUMSETS_MASK; + unsigned int n, line_size, num_sets; + + for ( n = CLIDR_CTYPEn_LEVELS; n != 0; n-- ) + { + uint8_t ctype_n = (clidr_el1 >> CLIDR_CTYPEn_SHIFT(n)) & + CLIDR_CTYPEn_MASK; + + /* At least separate I/D caches (see Arm ARM DDI 0487H.a D13.2.27) */ + if ( ctype_n > 0b011 ) + break; + } + + if ( n == 0 ) + return 0; + + WRITE_SYSREG((n - 1) << CSSELR_LEVEL_SHIFT, CSSELR_EL1); + + isb(); + + ccsidr_el1 = READ_SYSREG(CCSIDR_EL1); + + /* Arm ARM: (Log2(Number of bytes in cache line)) - 4 */ + line_size = 1U << ((ccsidr_el1 & CCSIDR_LINESIZE_MASK) + 4); + + /* If FEAT_CCIDX is enabled, CCSIDR_EL1 has a different bit layout */ + if ( (id_aa64mmfr2_el1 >> ID_AA64MMFR2_CCIDX_SHIFT) & 0x7 ) + { + ccsidr_numsets_shift = CCSIDR_NUMSETS_SHIFT_FEAT_CCIDX; + ccsidr_numsets_mask = CCSIDR_NUMSETS_MASK_FEAT_CCIDX; + } + /* Arm ARM: (Number of sets in cache) - 1 */ + num_sets = ((ccsidr_el1 >> ccsidr_numsets_shift) & ccsidr_numsets_mask) + 1; + + printk(XENLOG_INFO "LLC found: L%u (line size: %u bytes, sets num: %u)\n", + n, line_size, num_sets); + + /* Restore value in CSSELR_EL1 */ + WRITE_SYSREG(csselr_el1, CSSELR_EL1); + isb(); + + return line_size * num_sets; +} + +void __init arch_llc_coloring_init(void) {} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 59dd9bb25a..14cb023783 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -746,6 +747,8 @@ void asmlinkage __init start_xen(unsigned long boot_phys_offset, printk("Command line: %s\n", cmdline); cmdline_parse(cmdline); + llc_coloring_init(); + setup_mm(); /* Parse the ACPI tables for possible boot-time configuration */ From patchwork Mon Jan 29 17:17:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536086 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 A8B91C48286 for ; Mon, 29 Jan 2024 17:19:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673064.1047246 (Exim 4.92) (envelope-from ) id 1rUVI3-0006cs-Km; Mon, 29 Jan 2024 17:19:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673064.1047246; Mon, 29 Jan 2024 17:19:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI3-0006cl-GZ; Mon, 29 Jan 2024 17:19:23 +0000 Received: by outflank-mailman (input) for mailman id 673064; Mon, 29 Jan 2024 17:19:22 +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 1rUVI2-0005vY-2o for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:22 +0000 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [2a00:1450:4864:20::530]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 89dc4d19-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:20 +0100 (CET) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-558f523c072so3313737a12.2 for ; Mon, 29 Jan 2024 09:19:20 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:19 -0800 (PST) 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: 89dc4d19-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548759; x=1707153559; 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=A7L8IWQ2YLMp5Yv8zv1GVRcHauldwszXKWY+GEdg7KM=; b=PCxKwyjTV68nj3qghZOdmF5l/6qONRcfNgGWOD8Kmpcpc7RsVMmAk9+CuIUYOjkWId ybaxL3MEP+Ku+BT2exaPAfIH3Me2TGvLT9ErmCbn2OUx2YprEjOFLEdp2yGb4W91AdoU QiOlPJ1X8dS3BppuTexoOlhLsySw5FZcjYs1R6Z/KqMy1PKl3K3S8KT2fDrF9VE/twll mqzCIQPlq76upMAfc+gsCYQWCRAqssMjff8sxOKAN6YPqrYc7Lxc9reNOAtDCWty0eTf HjQsp7+BnoN5HxBzkseih4Iidqdf/MiApKzRz9XhXylt4cKwGJx03BIZpQUNHO+EJON4 SVSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548759; x=1707153559; 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=A7L8IWQ2YLMp5Yv8zv1GVRcHauldwszXKWY+GEdg7KM=; b=IloEje06Pqv1PdLd4NPGmdI1HmToePoX6j3uha6APLJ1fw/lL1TOjc4/dBG483F0cu QsSM3YVd8OFDSVP0qwQyazWNGCGRnKRuw8TWGbDDhvn3tBB9ckH2/3PLhafnZa9jHws0 0++53Ppa1u6+yqXs/pNjuP9V2aOKW0Pdm+F9x7i86Kz80AlP6kPidyopQ77+dQDVGEuN hpPOxQ/F7rRgwNtLzEjrFwxbhEwE0vyCsIC504AiQgrgGHL22UkPglAtGOD3jqWzkvHT Oz2Zp9l5Nx87iwX6STPy4mQfVp7yIlwzyXqn/ZzEZ0IK2BI78NERglabYy7dkxACyHiO hf8A== X-Gm-Message-State: AOJu0YwkSWQMrQ+mIkll16pUQTAVEMCpczBgZpZFjluiZLaJJY4Mm6j0 Y3RjkTok9fUNQC6nb8wQF61Bg4CNfzh/JYEDuTpirFayZ4CX9ZAP7GrZYskY5pmdi23U8oNUp0n jGVQ= X-Google-Smtp-Source: AGHT+IHc6SGBI13PCY9sFTXFAMu8+NtauaSDaSehtuJBHrYcFAt8bSCual35VaQSkMR/T1CIofLTcw== X-Received: by 2002:a05:6402:40d4:b0:55d:3b94:a1c6 with SMTP id z20-20020a05640240d400b0055d3b94a1c6mr4683564edb.0.1706548759204; Mon, 29 Jan 2024 09:19:19 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v6 03/15] xen/arm: permit non direct-mapped Dom0 construction Date: Mon, 29 Jan 2024 18:17:59 +0100 Message-Id: <20240129171811.21382-4-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Cache coloring requires Dom0 not to be direct-mapped because of its non contiguous mapping nature, so allocate_memory() is needed in this case. 8d2c3ab18cc1 ("arm/dom0less: put dom0less feature code in a separate module") moved allocate_memory() in dom0less_build.c. In order to use it in Dom0 construction bring it back to domain_build.c and declare it in domain_build.h. Signed-off-by: Carlo Nonato --- v6: - new patch --- xen/arch/arm/dom0less-build.c | 43 --------------------- xen/arch/arm/domain_build.c | 50 +++++++++++++++++++++++-- xen/arch/arm/include/asm/domain_build.h | 1 + 3 files changed, 48 insertions(+), 46 deletions(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 1142f7f74a..992080e61a 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -49,49 +49,6 @@ bool __init is_dom0less_mode(void) return ( !dom0found && domUfound ); } -static void __init allocate_memory(struct domain *d, struct kernel_info *kinfo) -{ - unsigned int i; - paddr_t bank_size; - - printk(XENLOG_INFO "Allocating mappings totalling %ldMB for %pd:\n", - /* Don't want format this as PRIpaddr (16 digit hex) */ - (unsigned long)(kinfo->unassigned_mem >> 20), d); - - kinfo->mem.nr_banks = 0; - bank_size = MIN(GUEST_RAM0_SIZE, kinfo->unassigned_mem); - if ( !allocate_bank_memory(d, kinfo, gaddr_to_gfn(GUEST_RAM0_BASE), - bank_size) ) - goto fail; - - bank_size = MIN(GUEST_RAM1_SIZE, kinfo->unassigned_mem); - if ( !allocate_bank_memory(d, kinfo, gaddr_to_gfn(GUEST_RAM1_BASE), - bank_size) ) - goto fail; - - if ( kinfo->unassigned_mem ) - goto fail; - - for( i = 0; i < kinfo->mem.nr_banks; i++ ) - { - printk(XENLOG_INFO "%pd BANK[%d] %#"PRIpaddr"-%#"PRIpaddr" (%ldMB)\n", - d, - i, - kinfo->mem.bank[i].start, - kinfo->mem.bank[i].start + kinfo->mem.bank[i].size, - /* Don't want format this as PRIpaddr (16 digit hex) */ - (unsigned long)(kinfo->mem.bank[i].size >> 20)); - } - - return; - -fail: - panic("Failed to allocate requested domain memory." - /* Don't want format this as PRIpaddr (16 digit hex) */ - " %ldKB unallocated. Fix the VMs configurations.\n", - (unsigned long)kinfo->unassigned_mem >> 10); -} - #ifdef CONFIG_VGICV2 static int __init make_gicv2_domU_node(struct kernel_info *kinfo) { diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 46161848dc..a9e5310aff 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -415,7 +415,6 @@ static void __init allocate_memory_11(struct domain *d, } } -#ifdef CONFIG_DOM0LESS_BOOT bool __init allocate_bank_memory(struct domain *d, struct kernel_info *kinfo, gfn_t sgfn, paddr_t tot_size) { @@ -477,7 +476,49 @@ bool __init allocate_bank_memory(struct domain *d, struct kernel_info *kinfo, return true; } -#endif + +void __init allocate_memory(struct domain *d, struct kernel_info *kinfo) +{ + unsigned int i; + paddr_t bank_size; + + printk(XENLOG_INFO "Allocating mappings totalling %ldMB for %pd:\n", + /* Don't want format this as PRIpaddr (16 digit hex) */ + (unsigned long)(kinfo->unassigned_mem >> 20), d); + + kinfo->mem.nr_banks = 0; + bank_size = MIN(GUEST_RAM0_SIZE, kinfo->unassigned_mem); + if ( !allocate_bank_memory(d, kinfo, gaddr_to_gfn(GUEST_RAM0_BASE), + bank_size) ) + goto fail; + + bank_size = MIN(GUEST_RAM1_SIZE, kinfo->unassigned_mem); + if ( !allocate_bank_memory(d, kinfo, gaddr_to_gfn(GUEST_RAM1_BASE), + bank_size) ) + goto fail; + + if ( kinfo->unassigned_mem ) + goto fail; + + for( i = 0; i < kinfo->mem.nr_banks; i++ ) + { + printk(XENLOG_INFO "%pd BANK[%d] %#"PRIpaddr"-%#"PRIpaddr" (%ldMB)\n", + d, + i, + kinfo->mem.bank[i].start, + kinfo->mem.bank[i].start + kinfo->mem.bank[i].size, + /* Don't want format this as PRIpaddr (16 digit hex) */ + (unsigned long)(kinfo->mem.bank[i].size >> 20)); + } + + return; + +fail: + panic("Failed to allocate requested domain memory." + /* Don't want format this as PRIpaddr (16 digit hex) */ + " %ldKB unallocated. Fix the VMs configurations.\n", + (unsigned long)kinfo->unassigned_mem >> 10); +} /* * When PCI passthrough is available we want to keep the @@ -2073,7 +2114,10 @@ static int __init construct_dom0(struct domain *d) /* type must be set before allocate_memory */ d->arch.type = kinfo.type; #endif - allocate_memory_11(d, &kinfo); + if ( is_domain_direct_mapped(d) ) + allocate_memory_11(d, &kinfo); + else + allocate_memory(d, &kinfo); find_gnttab_region(d, &kinfo); rc = process_shm_chosen(d, &kinfo); diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include/asm/domain_build.h index da9e6025f3..b8e171e5cc 100644 --- a/xen/arch/arm/include/asm/domain_build.h +++ b/xen/arch/arm/include/asm/domain_build.h @@ -8,6 +8,7 @@ typedef __be32 gic_interrupt_t[3]; bool allocate_bank_memory(struct domain *d, struct kernel_info *kinfo, gfn_t sgfn, paddr_t tot_size); +void allocate_memory(struct domain *d, struct kernel_info *kinfo); int construct_domain(struct domain *d, struct kernel_info *kinfo); int domain_fdt_begin_node(void *fdt, const char *name, uint64_t unit); int make_chosen_node(const struct kernel_info *kinfo); From patchwork Mon Jan 29 17:18:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536098 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 AD6C7C48292 for ; Mon, 29 Jan 2024 17:19:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673065.1047256 (Exim 4.92) (envelope-from ) id 1rUVI5-0006sQ-2X; Mon, 29 Jan 2024 17:19:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673065.1047256; Mon, 29 Jan 2024 17:19:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI4-0006sI-Tx; Mon, 29 Jan 2024 17:19:24 +0000 Received: by outflank-mailman (input) for mailman id 673065; Mon, 29 Jan 2024 17:19:23 +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 1rUVI3-0005vY-2s for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:23 +0000 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [2a00:1450:4864:20::533]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8a7c0322-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:21 +0100 (CET) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-55ad2a47b7aso2867033a12.3 for ; Mon, 29 Jan 2024 09:19:21 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:19 -0800 (PST) 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: 8a7c0322-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548760; x=1707153560; 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=iIa5rMBLPGQ7jfnyxO46jyMXIeNANfVTdO7DqWxwb4c=; b=0bBIkWqyMluE7NrkadFknPdyeo/VGnswpdj9g9pUTVsz4CNCqpK3zDsdYzY1sQd7Zu 6tRXuIfl2p/P49daegDEtiRvgQ5OrIIucLxSbd3pqOXJu7hcYMd5KVAhM9tA6i5foJih tNWYSbkfRHyxpSF7k4Xaon9UlhRrUr1Hm9PoIju7HaD5EUgWpasrfAZaaBpw17w4kWVe T8yDhn8WR0z/xCI7IZbpnyaoqFBOVnF8lV3mQy4XlLRr0aPig3wJF3aqJCf2VD153UoZ v6sMknWjaM9w/7rMPFraAw7sNO7wDT7ZHObPjhgMa7Bl1W3wjLg3jJvs4gmako/SlJfk fxLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548760; x=1707153560; 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=iIa5rMBLPGQ7jfnyxO46jyMXIeNANfVTdO7DqWxwb4c=; b=McVZpwsA/ECJJkbpKeQKPAK9qNNxC0X9Y8nKum8K4sea2gl4wr7thgHIC2G9t4xXRb 3uJP+cyD2syNENnTxo1rLQ2RL5FZIzW7AvxVOnqhAHEBygwsHDV5YHbsx6CXg5Beiv3O dszMv0M8ZbcELe/5G3s8DYKw8va5kuUnvhaaL58tvlsx+OY9psMefcxvAUuj7phhGSQ1 Hj4DqRm9hYX2R/bFqnjkGQQv1U2ZnnIVHq6Yp5l/OsWmL20T2FXwLXmaExOg5u17ae5R sgmCx/0Az42UcaTr3B1nmmySbOL+ns9UnkBr4/ESbFejrEafsmlmDihqriA9NOShFWCj v0rQ== X-Gm-Message-State: AOJu0YwNDVJpxVmSBoOuBESCa2pFd6bYOdRadjJ9xPe3/bltCYOhfowz LOaqVsFLj7t5C8b0UjbpJRjiUp0mDFuP9ozQBghe3wX2DVRjiI8IMLOC/fu4MOeNAQWCbIeweDC PXf4= X-Google-Smtp-Source: AGHT+IHLLjWbB9yMguzQrhksnw/TcTzEZ1IjvtsAG0LjISoDSw4ezhsFSU0FMy/J2KXuxCp8BBSGiQ== X-Received: by 2002:aa7:cb53:0:b0:55f:19c4:600c with SMTP id w19-20020aa7cb53000000b0055f19c4600cmr1301080edt.37.1706548760210; Mon, 29 Jan 2024 09:19:20 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Marco Solieri Subject: [PATCH v6 04/15] xen/arm: add Dom0 cache coloring support Date: Mon, 29 Jan 2024 18:18:00 +0100 Message-Id: <20240129171811.21382-5-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Add a command line parameter to allow the user to set the coloring configuration for Dom0. A common configuration syntax for cache colors is introduced and documented. Take the opportunity to also add: - default configuration notion. - function to check well-formed configurations. Direct mapping Dom0 isn't possible when coloring is enabled, so CDF_directmap flag is removed when creating it. Based on original work from: Luca Miccio Signed-off-by: Carlo Nonato Signed-off-by: Marco Solieri --- v6: - moved domain_llc_coloring_free() in this patch - removed domain_alloc_colors() in favor of a more explicit allocation - parse_color_config() now accepts the size of the array to be filled - allocate_memory() moved in another patch v5: - Carlo Nonato as the new author - moved dom0 colors parsing (parse_colors()) in this patch - added dom0_set_llc_colors() to set dom0 colors after creation - moved color allocation and checking in this patch - error handling when allocating color arrays - FIXME: copy pasted allocate_memory() cause it got moved v4: - dom0 colors are dynamically allocated as for any other domain (colors are duplicated in dom0_colors and in the new array, but logic is simpler) --- docs/misc/cache-coloring.rst | 29 ++++++ docs/misc/xen-command-line.pandoc | 9 ++ xen/arch/arm/domain_build.c | 10 +- xen/common/domain.c | 3 + xen/common/llc-coloring.c | 153 ++++++++++++++++++++++++++++++ xen/include/xen/llc-coloring.h | 3 + 6 files changed, 206 insertions(+), 1 deletion(-) diff --git a/docs/misc/cache-coloring.rst b/docs/misc/cache-coloring.rst index 0535b5c656..c347725525 100644 --- a/docs/misc/cache-coloring.rst +++ b/docs/misc/cache-coloring.rst @@ -85,6 +85,35 @@ More specific documentation is available at `docs/misc/xen-command-line.pandoc`. +----------------------+-------------------------------+ | ``llc-way-size`` | set the LLC way size | +----------------------+-------------------------------+ +| ``dom0-llc-colors`` | Dom0 color configuration | ++----------------------+-------------------------------+ + +Colors selection format +*********************** + +Regardless of the memory pool that has to be colored (Xen, Dom0/DomUs), +the color selection can be expressed using the same syntax. In particular a +comma-separated list of colors or ranges of colors is used. +Ranges are hyphen-separated intervals (such as `0-4`) and are inclusive on both +sides. + +Note that: + +- no spaces are allowed between values. +- no overlapping ranges or duplicated colors are allowed. +- values must be written in ascending order. + +Examples: + ++-------------------+-----------------------------+ +| **Configuration** | **Actual selection** | ++-------------------+-----------------------------+ +| 1-2,5-8 | [1, 2, 5, 6, 7, 8] | ++-------------------+-----------------------------+ +| 4-8,10,11,12 | [4, 5, 6, 7, 8, 10, 11, 12] | ++-------------------+-----------------------------+ +| 0 | [0] | ++-------------------+-----------------------------+ Known issues and limitations **************************** diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 11f9f209d1..25da997b5b 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -963,6 +963,15 @@ Controls for the dom0 IOMMU setup. Specify a list of IO ports to be excluded from dom0 access. +### dom0-llc-colors +> `= List of [ | - ]` + +> Default: `All available LLC colors` + +Specify dom0 LLC color configuration. This options is available only when +`CONFIG_LLC_COLORING` is enabled. If the parameter is not set, all available +colors are used. + ### dom0_max_vcpus Either: diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a9e5310aff..e380d25dca 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -2161,6 +2162,7 @@ void __init create_dom0(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; + unsigned int flags = CDF_privileged; int rc; /* The vGIC for DOM0 is exactly emulating the hardware GIC */ @@ -2188,10 +2190,16 @@ void __init create_dom0(void) panic("SVE vector length error\n"); } - dom0 = domain_create(0, &dom0_cfg, CDF_privileged | CDF_directmap); + if ( !llc_coloring_enabled ) + flags |= CDF_directmap; + + dom0 = domain_create(0, &dom0_cfg, flags); if ( IS_ERR(dom0) ) panic("Error creating domain 0 (rc = %ld)\n", PTR_ERR(dom0)); + if ( llc_coloring_enabled && (rc = dom0_set_llc_colors(dom0)) ) + panic("Error initializing LLC coloring for domain 0 (rc = %d)", rc); + if ( alloc_dom0_vcpu0(dom0) == NULL ) panic("Error creating domain 0 vcpu0\n"); diff --git a/xen/common/domain.c b/xen/common/domain.c index f6f5574996..f144b54f4f 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1208,6 +1209,8 @@ void domain_destroy(struct domain *d) BUG_ON(!d->is_dying); + domain_llc_coloring_free(d); + /* May be already destroyed, or get_domain() can race us. */ if ( atomic_cmpxchg(&d->refcnt, 0, DOMAIN_DESTROYED) != 0 ) return; diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c index 10729e70c1..983de44a47 100644 --- a/xen/common/llc-coloring.c +++ b/xen/common/llc-coloring.c @@ -17,6 +17,63 @@ size_param("llc-way-size", llc_way_size); /* Number of colors available in the LLC */ static unsigned int __ro_after_init max_nr_colors = CONFIG_NR_LLC_COLORS; +static unsigned int __initdata dom0_colors[CONFIG_NR_LLC_COLORS]; +static unsigned int __initdata dom0_num_colors; + +/* + * Parse the coloring configuration given in the buf string, following the + * syntax below. + * + * COLOR_CONFIGURATION ::= COLOR | RANGE,...,COLOR | RANGE + * RANGE ::= COLOR-COLOR + * + * Example: "0,2-6,15-16" represents the set of colors: 0,2,3,4,5,6,15,16. + */ +static int parse_color_config(const char *buf, unsigned int *colors, + unsigned int num_colors, unsigned int *num_parsed) +{ + const char *s = buf; + + if ( !colors || !num_colors ) + return -EINVAL; + + *num_parsed = 0; + + while ( *s != '\0' ) + { + if ( *s != ',' ) + { + unsigned int color, start, end; + + start = simple_strtoul(s, &s, 0); + + if ( *s == '-' ) /* Range */ + { + s++; + end = simple_strtoul(s, &s, 0); + } + else /* Single value */ + end = start; + + if ( start > end || (end - start) > (UINT_MAX - *num_parsed) || + (*num_parsed + (end - start)) >= num_colors ) + return -EINVAL; + for ( color = start; color <= end; color++ ) + colors[(*num_parsed)++] = color; + } + else + s++; + } + + return *s ? -EINVAL : 0; +} + +static int __init parse_dom0_colors(const char *s) +{ + return parse_color_config(s, dom0_colors, max_nr_colors, &dom0_num_colors); +} +custom_param("dom0-llc-colors", parse_dom0_colors); + static void print_colors(const unsigned int *colors, unsigned int num_colors) { unsigned int i; @@ -47,6 +104,29 @@ static void dump_coloring_info(unsigned char key) printk("Number of LLC colors supported: %u\n", max_nr_colors); } +static bool check_colors(const unsigned int *colors, unsigned int num_colors) +{ + unsigned int i; + + if ( num_colors > max_nr_colors ) + { + printk(XENLOG_ERR "Number of LLC colors requested > %u\n", + max_nr_colors); + return false; + } + + for ( i = 0; i < num_colors; i++ ) + { + if ( colors[i] >= max_nr_colors ) + { + printk(XENLOG_ERR "LLC color %u >= %u\n", colors[i], max_nr_colors); + return false; + } + } + + return true; +} + void __init llc_coloring_init(void) { if ( !llc_way_size && !(llc_way_size = get_llc_way_size()) ) @@ -70,12 +150,85 @@ void __init llc_coloring_init(void) arch_llc_coloring_init(); } +void domain_llc_coloring_free(struct domain *d) +{ + xfree(__va(__pa(d->llc_colors))); +} + void domain_dump_llc_colors(const struct domain *d) { printk("Domain %pd has %u LLC colors: ", d, d->num_llc_colors); print_colors(d->llc_colors, d->num_llc_colors); } +static unsigned int *alloc_colors(unsigned int num_colors) +{ + unsigned int *colors; + + if ( num_colors > max_nr_colors ) + return NULL; + + colors = xmalloc_array(unsigned int, num_colors); + if ( !colors ) + return NULL; + + return colors; +} + +static int domain_check_colors(const struct domain *d) +{ + if ( !d->num_llc_colors ) + { + printk(XENLOG_ERR "No LLC color config found for %pd\n", d); + return -ENODATA; + } + else if ( !check_colors(d->llc_colors, d->num_llc_colors) ) + { + printk(XENLOG_ERR "Bad LLC color config for %pd\n", d); + return -EINVAL; + } + + return 0; +} + +static int domain_set_default_colors(struct domain *d) +{ + unsigned int *colors = alloc_colors(max_nr_colors); + unsigned int i; + + if ( !colors ) + return -ENOMEM; + + printk(XENLOG_WARNING + "LLC color config not found for %pd, using default\n", d); + + for ( i = 0; i < max_nr_colors; i++ ) + colors[i] = i; + + d->llc_colors = colors; + d->num_llc_colors = max_nr_colors; + + return 0; +} + +int __init dom0_set_llc_colors(struct domain *d) +{ + unsigned int *colors; + + if ( !dom0_num_colors ) + return domain_set_default_colors(d); + + colors = alloc_colors(dom0_num_colors); + if ( !colors ) + return -ENOMEM; + + memcpy(colors, dom0_colors, sizeof(unsigned int) * dom0_num_colors); + d->llc_colors = colors; + d->num_llc_colors = dom0_num_colors; + + return domain_check_colors(d); +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/llc-coloring.h b/xen/include/xen/llc-coloring.h index 5e12eb426f..1a73080c98 100644 --- a/xen/include/xen/llc-coloring.h +++ b/xen/include/xen/llc-coloring.h @@ -14,16 +14,19 @@ extern bool llc_coloring_enabled; void llc_coloring_init(void); +void domain_llc_coloring_free(struct domain *d); void domain_dump_llc_colors(const struct domain *d); #else #define llc_coloring_enabled false static inline void llc_coloring_init(void) {} +static inline void domain_llc_coloring_free(struct domain *d) {} static inline void domain_dump_llc_colors(const struct domain *d) {} #endif unsigned int get_llc_way_size(void); void arch_llc_coloring_init(void); +int dom0_set_llc_colors(struct domain *d); #endif /* __COLORING_H__ */ From patchwork Mon Jan 29 17:18:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536089 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 0F3A9C4828F for ; Mon, 29 Jan 2024 17:19:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673066.1047261 (Exim 4.92) (envelope-from ) id 1rUVI5-0006wB-Fl; Mon, 29 Jan 2024 17:19:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673066.1047261; Mon, 29 Jan 2024 17:19:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI5-0006vQ-8r; Mon, 29 Jan 2024 17:19:25 +0000 Received: by outflank-mailman (input) for mailman id 673066; Mon, 29 Jan 2024 17:19:24 +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 1rUVI4-0005vY-30 for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:24 +0000 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [2a00:1450:4864:20::22d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8b101d2e-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:22 +0100 (CET) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2cf1fd1cc5bso35531751fa.3 for ; Mon, 29 Jan 2024 09:19:22 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:20 -0800 (PST) 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: 8b101d2e-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548761; x=1707153561; 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=yQCxn/qSiO+Xlc2kHildMd99iJ3B4U7/tWBy/pimbzo=; b=l0ayDZ6B4oUSrK3TsvSHfF9bvVR6a2iQ2OSAKbpGy2zwMTIzG+l9qNqt1uq16x8UOL 77T3knYMAZybK9YgGNVHvr3Fcu3zl5s86XfRnsvsoVfbpDXE5+xL5b61SRmoL50MTFNN zO+c9Py3/wk30PO1bJdmO7/YJoLuP+w+GTKfc9/pT2O5rppOl2YH8B6v+aEuFZhs3vrA pDrC4Pzhv1IBFkEE2rsV5MqbbhVb0zTZjIanhU25lBLMtoxrCukUHNvTMqVWR3N8Kzhe cYQGSfYntCnROZM33FYzQLIoj6oiX8q+FWjLBAyU+efiTuMXTMohq/Tj9xjcthwd3bQd gfMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548761; x=1707153561; 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=yQCxn/qSiO+Xlc2kHildMd99iJ3B4U7/tWBy/pimbzo=; b=oeY6zNPcuiSIo0T917r/cO1jkYrt57NHBSgeyTbQ6sArpVYoR2IuUXap0Q5B9/nC7r lky38PCpP3jv2xjifKsIqTS6HsAwuRmigJOLqzRL7rXZSzNtla8qo/ydqhqNMcRBM6lP beQCsfQh2mfBCAoNTYToicAUdSQHmdz/mI0oepzy+MWQ7XwvcSGgwhmWWv3BKBgYlNry R0GjQzx1Kqxz15uz/Kx+kfcwIT5m23c7LVQ38E6UvJV3wCHb0vOYlX0djKTCZQQS/8xq QbarUbPYGXqJoE4jgpDjQKtk2SvBP+mX48pN6jP3z7qbV24Pj4sVAOoV64ga9QHPvXVJ I+iQ== X-Gm-Message-State: AOJu0YxnthTL8U85hyoEaLeV1cnNuAD6wQ0VwPnJ45pVAIdXgd6hOhH/ dpu+Q5Q+oIetMDZud4X0dYF0qtNd8OTA7rweowSfvEuN3SOhurZX8kIGJUcN/ohLJQXpGnUZ4Nz q4vg= X-Google-Smtp-Source: AGHT+IGXbU38Oy5XxZbVKZaWzBhOGFgRSdo5hfBtuIrJ1TbygxIFo+z/zFGXI1MhvagzFR4/Nmytew== X-Received: by 2002:a2e:86ca:0:b0:2cd:c811:6a24 with SMTP id n10-20020a2e86ca000000b002cdc8116a24mr5419271ljj.18.1706548761240; Mon, 29 Jan 2024 09:19:21 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Marco Solieri Subject: [PATCH v6 05/15] xen: extend domctl interface for cache coloring Date: Mon, 29 Jan 2024 18:18:01 +0100 Message-Id: <20240129171811.21382-6-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Update the domctl interface to allow the user to set coloring configurations from the toolstack. Implement also the functionality for arm64. Based on original work from: Luca Miccio Signed-off-by: Carlo Nonato Signed-off-by: Marco Solieri --- v6: - reverted the XEN_DOMCTL_INTERFACE_VERSION bump - reverted to uint32 for the guest handle - explicit padding added to the domctl struct - rewrote domain_set_llc_colors_domctl() to be more explicit v5: - added a new hypercall to set colors - uint for the guest handle v4: - updated XEN_DOMCTL_INTERFACE_VERSION --- xen/common/domctl.c | 11 +++++++++++ xen/common/llc-coloring.c | 25 +++++++++++++++++++++++++ xen/include/public/domctl.h | 9 +++++++++ xen/include/xen/llc-coloring.h | 3 +++ 4 files changed, 48 insertions(+) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index f5a71ee5f7..b6867d0602 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -858,6 +859,16 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) __HYPERVISOR_domctl, "h", u_domctl); break; + case XEN_DOMCTL_set_llc_colors: + if ( !llc_coloring_enabled ) + break; + + ret = domain_set_llc_colors_domctl(d, &op->u.set_llc_colors); + if ( ret == -EEXIST ) + printk(XENLOG_ERR + "Can't set LLC colors on an already created domain\n"); + break; + default: ret = arch_do_domctl(op, d, u_domctl); break; diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c index 983de44a47..aaf0606c00 100644 --- a/xen/common/llc-coloring.c +++ b/xen/common/llc-coloring.c @@ -4,6 +4,7 @@ * * Copyright (C) 2022 Xilinx Inc. */ +#include #include #include #include @@ -229,6 +230,30 @@ int __init dom0_set_llc_colors(struct domain *d) return domain_check_colors(d); } +int domain_set_llc_colors_domctl(struct domain *d, + const struct xen_domctl_set_llc_colors *config) +{ + unsigned int *colors; + + if ( d->num_llc_colors ) + return -EEXIST; + + if ( !config->num_llc_colors ) + return domain_set_default_colors(d); + + colors = alloc_colors(config->num_llc_colors); + if ( !colors ) + return -ENOMEM; + + if ( copy_from_guest(colors, config->llc_colors, config->num_llc_colors) ) + return -EFAULT; + + d->llc_colors = colors; + d->num_llc_colors = config->num_llc_colors; + + return domain_check_colors(d); +} + /* * Local variables: * mode: C diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a33f9ec32b..d090cdb2dd 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1190,6 +1190,13 @@ struct xen_domctl_vmtrace_op { typedef struct xen_domctl_vmtrace_op xen_domctl_vmtrace_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_vmtrace_op_t); +struct xen_domctl_set_llc_colors { + /* IN LLC coloring parameters */ + uint32_t num_llc_colors; + uint32_t padding; + XEN_GUEST_HANDLE_64(uint32) llc_colors; +}; + struct xen_domctl { uint32_t cmd; #define XEN_DOMCTL_createdomain 1 @@ -1277,6 +1284,7 @@ struct xen_domctl { #define XEN_DOMCTL_vmtrace_op 84 #define XEN_DOMCTL_get_paging_mempool_size 85 #define XEN_DOMCTL_set_paging_mempool_size 86 +#define XEN_DOMCTL_set_llc_colors 87 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 @@ -1339,6 +1347,7 @@ struct xen_domctl { struct xen_domctl_vuart_op vuart_op; struct xen_domctl_vmtrace_op vmtrace_op; struct xen_domctl_paging_mempool paging_mempool; + struct xen_domctl_set_llc_colors set_llc_colors; uint8_t pad[128]; } u; }; diff --git a/xen/include/xen/llc-coloring.h b/xen/include/xen/llc-coloring.h index 1a73080c98..a82081367f 100644 --- a/xen/include/xen/llc-coloring.h +++ b/xen/include/xen/llc-coloring.h @@ -28,6 +28,9 @@ unsigned int get_llc_way_size(void); void arch_llc_coloring_init(void); int dom0_set_llc_colors(struct domain *d); +int domain_set_llc_colors_domctl(struct domain *d, + const struct xen_domctl_set_llc_colors *config); + #endif /* __COLORING_H__ */ /* From patchwork Mon Jan 29 17:18:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536090 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 00C68C4828E for ; Mon, 29 Jan 2024 17:19:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673067.1047276 (Exim 4.92) (envelope-from ) id 1rUVI6-0007MK-OD; Mon, 29 Jan 2024 17:19:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673067.1047276; Mon, 29 Jan 2024 17:19:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI6-0007KD-KS; Mon, 29 Jan 2024 17:19:26 +0000 Received: by outflank-mailman (input) for mailman id 673067; Mon, 29 Jan 2024 17:19:25 +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 1rUVI5-0005vb-6O for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:25 +0000 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [2a00:1450:4864:20::529]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8bb57a4a-beca-11ee-98f5-efadbce2ee36; Mon, 29 Jan 2024 18:19:23 +0100 (CET) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-55c2c90c67dso3037151a12.1 for ; Mon, 29 Jan 2024 09:19:23 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:21 -0800 (PST) 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: 8bb57a4a-beca-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548762; x=1707153562; 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=FOxIWS7kq3ckWF1E4D6jcpkZDZGO+rTxDl+omr7l9nQ=; b=w4+REGsoTSRy3eqIElj7UnxWvk/SEELVa6pMS99MsgYijEL9qbLenAZ2elz+RlpFwm gaN3/SmqJoWdB9JVXGTRjYC7D3/pILWDJkmrPivHWvF9bo5kSh0twJdguX8yZQfImCHA 50eyiTzjRd5Ci8xVU5myM/i+0C0arws9kdAC690DwRFnKZ0qHy2pxP0jtWLRqTtSu2Wj 0EB4mHDFecZ7Rm7zHOwD/amBZyAR3nq0n7ETl5+VwBU8u0YAgtAuPaDJckKUYO1fBd4g 4ysE+y71P5gh3xcxZtLbioLdeDDGmA+o+XaDZiZRaJnLB92blN+uYiHFKv2hf3AoDtR9 1PqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548762; x=1707153562; 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=FOxIWS7kq3ckWF1E4D6jcpkZDZGO+rTxDl+omr7l9nQ=; b=fYXEK8J2BR+FEjuzJItbBCjdT/P5tZowwp3pfgJ5d+pFq0nddHyD2ynyh9bgrjyDPT 0YO0YT2hJXt7lgxRS58MTyIN8LRyWeSD3LukkqmMsGUL0rirIGY24PnJhTKNgZizW5MT emQ91fMRq+tUcl/2v0FajTAoQ1QWZ1XEVfqYvMaICDb3hi6lQHLptOYPF4yEo16HyJEW oEQLIy/CZn3jTlKX85FOTuWLTuXsmAhScjtfEiP8AckfQgP7xzG6/8CmMxHOvJUmslVj fruCT8D8pYnpXDRHL6b8UaTp/uTLs0jnZXw0c/DFN/i43KHvf6wvHFfF7HfqojGdSKkA pZOQ== X-Gm-Message-State: AOJu0YyecsLyDKsyIjI8SpeqRag/9VGCmWyN55aSLWMztK9OlD3kb99f ta7XEec7jIvwPUa6vy5f6cGy3vp8KzBS9JwkAiph1yfs7XZySuM3rz29wbfmc4RRE6fu65IO9X+ V2eI= X-Google-Smtp-Source: AGHT+IHACTg7Xvkm2VBIy7YD6NVoSqLao3kbMq+slNZlMJjM07qCu0XOMUxs5m7WFXSUPQyUavqtzA== X-Received: by 2002:a05:6402:358b:b0:55c:876c:b61c with SMTP id y11-20020a056402358b00b0055c876cb61cmr5477827edc.7.1706548762289; Mon, 29 Jan 2024 09:19:22 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Wei Liu , Anthony PERARD , Juergen Gross , Marco Solieri Subject: [PATCH v6 06/15] tools: add support for cache coloring configuration Date: Mon, 29 Jan 2024 18:18:02 +0100 Message-Id: <20240129171811.21382-7-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Add a new "llc_colors" parameter that defines the LLC color assignment for a domain. The user can specify one or more color ranges using the same syntax used everywhere else for color config described in the documentation. The parameter is defined as a list of strings that represent the color ranges. Documentation is also added. Based on original work from: Luca Miccio Signed-off-by: Carlo Nonato Signed-off-by: Marco Solieri --- v6: - no edits v5: - added LIBXL_HAVE_BUILDINFO_LLC_COLORS - moved color configuration in xc_domain_set_llc_colors() cause of the new hypercall v4: - removed overlapping color ranges checks during parsing - moved hypercall buffer initialization in libxenctrl --- docs/man/xl.cfg.5.pod.in | 10 +++++++++ tools/include/libxl.h | 5 +++++ tools/include/xenctrl.h | 9 ++++++++ tools/libs/ctrl/xc_domain.c | 34 ++++++++++++++++++++++++++++ tools/libs/light/libxl_create.c | 9 ++++++++ tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 38 +++++++++++++++++++++++++++++++- 7 files changed, 105 insertions(+), 1 deletion(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index ea8d41727d..d1140976d4 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -3038,6 +3038,16 @@ raised. =back +=over 4 + +=item B + +Specify the Last Level Cache (LLC) color configuration for the guest. +B can be either a single color value or a hypen-separated closed +interval of colors (such as "0-4"). + +=back + =head3 x86 =over 4 diff --git a/tools/include/libxl.h b/tools/include/libxl.h index f1652b1664..24aa2c1c2e 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -1347,6 +1347,11 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src); */ #define LIBXL_HAVE_BUILDINFO_HVM_SYSTEM_FIRMWARE +/* + * The libxl_domain_build_info has the llc_colors array. + */ +#define LIBXL_HAVE_BUILDINFO_LLC_COLORS 1 + /* * ERROR_REMUS_XXX error code only exists from Xen 4.5, Xen 4.6 and it * is changed to ERROR_CHECKPOINT_XXX in Xen 4.7 diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 2ef8b4e054..4b541fffd2 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2653,6 +2653,15 @@ int xc_livepatch_replace(xc_interface *xch, char *name, uint32_t timeout, uint32 int xc_domain_cacheflush(xc_interface *xch, uint32_t domid, xen_pfn_t start_pfn, xen_pfn_t nr_pfns); +/* + * Set LLC colors for a domain. + * This is an internal hypercall. It can only be used directly after domain + * creation. An attempt to use it afterwards will result in an error. + */ +int xc_domain_set_llc_colors(xc_interface *xch, uint32_t domid, + const unsigned int *llc_colors, + unsigned int num_llc_colors); + #if defined(__arm__) || defined(__aarch64__) int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, uint32_t overlay_fdt_size, uint8_t overlay_op); diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c index f2d9d14b4d..ad02288659 100644 --- a/tools/libs/ctrl/xc_domain.c +++ b/tools/libs/ctrl/xc_domain.c @@ -2180,6 +2180,40 @@ int xc_domain_soft_reset(xc_interface *xch, domctl.domain = domid; return do_domctl(xch, &domctl); } + +int xc_domain_set_llc_colors(xc_interface *xch, uint32_t domid, + const unsigned int *llc_colors, + unsigned int num_llc_colors) +{ + struct xen_domctl domctl = {}; + DECLARE_HYPERCALL_BUFFER(uint32_t, local); + int ret = -1; + + if ( num_llc_colors ) + { + size_t bytes = sizeof(uint32_t) * num_llc_colors; + + local = xc_hypercall_buffer_alloc(xch, local, bytes); + if ( local == NULL ) + { + PERROR("Could not allocate LLC colors for set_llc_colors"); + return -ENOMEM; + } + memcpy(local, llc_colors, bytes); + set_xen_guest_handle(domctl.u.set_llc_colors.llc_colors, local); + } + + domctl.cmd = XEN_DOMCTL_set_llc_colors; + domctl.domain = domid; + domctl.u.set_llc_colors.num_llc_colors = num_llc_colors; + + ret = do_domctl(xch, &domctl); + + if ( local ) + xc_hypercall_buffer_free(xch, local); + + return ret; +} /* * Local variables: * mode: C diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c index 0008fac607..4db9f574f6 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -726,6 +726,15 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, /* A new domain now exists */ *domid = local_domid; + ret = xc_domain_set_llc_colors(ctx->xch, local_domid, + b_info->llc_colors, + b_info->num_llc_colors); + if (ret < 0) { + LOGED(ERROR, local_domid, "LLC colors allocation failed"); + rc = ERROR_FAIL; + goto out; + } + rc = libxl__is_domid_recent(gc, local_domid, &recent); if (rc) goto out; diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl index 899ad30969..0208283492 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -610,6 +610,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("ioports", Array(libxl_ioport_range, "num_ioports")), ("irqs", Array(uint32, "num_irqs")), ("iomem", Array(libxl_iomem_range, "num_iomem")), + ("llc_colors", Array(uint32, "num_llc_colors")), ("claim_mode", libxl_defbool), ("event_channels", uint32), ("kernel", string), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 9b358f11b8..0ad1e2109e 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1294,7 +1294,7 @@ void parse_config_data(const char *config_source, XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms, *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_devs; XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs, - *mca_caps, *smbios; + *mca_caps, *smbios, *llc_colors; int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps; int num_smbios; int pci_power_mgmt = 0; @@ -1302,6 +1302,7 @@ void parse_config_data(const char *config_source, int pci_permissive = 0; int pci_seize = 0; int i, e; + int num_llc_colors; char *kernel_basename; libxl_domain_create_info *c_info = &d_config->c_info; @@ -1445,6 +1446,41 @@ void parse_config_data(const char *config_source, if (!xlu_cfg_get_long (config, "maxmem", &l, 0)) b_info->max_memkb = l * 1024; + if (!xlu_cfg_get_list(config, "llc_colors", &llc_colors, &num_llc_colors, 0)) { + int cur_index = 0; + + b_info->num_llc_colors = 0; + for (i = 0; i < num_llc_colors; i++) { + uint32_t start = 0, end = 0, k; + + buf = xlu_cfg_get_listitem(llc_colors, i); + if (!buf) { + fprintf(stderr, + "xl: Can't get element %d in LLC color list\n", i); + exit(1); + } + + if (sscanf(buf, "%" SCNu32 "-%" SCNu32, &start, &end) != 2) { + if (sscanf(buf, "%" SCNu32, &start) != 1) { + fprintf(stderr, "xl: Invalid LLC color range: %s\n", buf); + exit(1); + } + end = start; + } else if (start > end) { + fprintf(stderr, + "xl: Start LLC color is greater than end: %s\n", buf); + exit(1); + } + + b_info->num_llc_colors += (end - start) + 1; + b_info->llc_colors = (uint32_t *)realloc(b_info->llc_colors, + sizeof(*b_info->llc_colors) * b_info->num_llc_colors); + + for (k = start; k <= end; k++) + b_info->llc_colors[cur_index++] = k; + } + } + if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) { vcpus = l; if (libxl_cpu_bitmap_alloc(ctx, &b_info->avail_vcpus, l)) { From patchwork Mon Jan 29 17:18:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536084 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 766B0C47DDB for ; Mon, 29 Jan 2024 17:19:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673068.1047286 (Exim 4.92) (envelope-from ) id 1rUVI8-0007em-A3; Mon, 29 Jan 2024 17:19:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673068.1047286; Mon, 29 Jan 2024 17:19:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI8-0007ed-5B; Mon, 29 Jan 2024 17:19:28 +0000 Received: by outflank-mailman (input) for mailman id 673068; Mon, 29 Jan 2024 17:19:26 +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 1rUVI6-0005vb-6X for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:26 +0000 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [2a00:1450:4864:20::532]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8c250c6d-beca-11ee-98f5-efadbce2ee36; Mon, 29 Jan 2024 18:19:24 +0100 (CET) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-55eee4a042eso1826854a12.0 for ; Mon, 29 Jan 2024 09:19:24 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:22 -0800 (PST) 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: 8c250c6d-beca-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548763; x=1707153563; 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=kd9miIuow0BSRA/mBkMSExaPwqKXz3kDkiwlSiWY+B4=; b=YILSwGn9Sntoo7c2TagcwF/e8aZis6MwIaMDKjbOmgjpERiav2OBF7FoK+TuXvpOv3 tTzPQJi7IoYi7AObCo2c5mr9BuGIfI5w3GHj/odO4nsT5EqoGRMyViHyhp1sB4VaLoUU zXxx5SUyKv3B0aymc3opCT74rVFpdvvcI+fXo6W6NuIKQKcskkl/cPhc429PLr2+ceHE lmf6rLYJgDlBsfKwbvEJpi8ITcnc3Eznwb4TN4OcMN3NQXm1wZ+GsW/GCC942RLO/cTI MxfRJmG6cQpgSOPnA7L3xpqy43YZyrFTkgNUa/2ebONliobmLsmuwfEmaSFdM51Wwfzk lCBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548763; x=1707153563; 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=kd9miIuow0BSRA/mBkMSExaPwqKXz3kDkiwlSiWY+B4=; b=ndKVgIyUN5O+vydHXkJh0yB1FOmcVgZX6U1B/TzYRWouXIsnKSTNKWGMPQXK5g4iXL 3dWJZWW6Xd1khnqUNo9rRrIWk2+5AjnEBzkWVywSAD3JNgHjImfANBp03NlYX4wdnpgw sOXIVV4dFYLfHnSMRVU64SarP7NLhkYgyaa8tB7htuqY/LZf1fisWcz7mK2Ey19miCtN c11EQRxew/2RDffElg/GfxavQZmX0hiawZPc55HYo4GPNJNtmRu2HVYlaV6zTjoBEYZ9 8dWEkzlVXFOYdanlPONPLmVp9uyVIhmDbRVi81sVm9erdFPyLUU/Kvob9Sa+PYMRpZyu LDaw== X-Gm-Message-State: AOJu0YyU0k6ea2tH7VpjCrbULgerEbmzKZP44bEPv/0lKDly8QoA4Xx3 DbmRS8tAk9b//6DIbELtKVSDMEYM7cCRpWC7MNk1rNoWjyE6SVD24zFRXCjmN2pBetSUv5aysRL Bnvo= X-Google-Smtp-Source: AGHT+IHA3GyKmzTknu0xDrqSyZtKBYr/88PUTlzm4Vz+aC0G/wQTLAnjXEd2qFQNtW5kr5XXujwQJA== X-Received: by 2002:a05:6402:3509:b0:55e:c6e3:5e24 with SMTP id b9-20020a056402350900b0055ec6e35e24mr3633682edd.36.1706548763268; Mon, 29 Jan 2024 09:19:23 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , Marco Solieri Subject: [PATCH v6 07/15] xen/arm: add support for cache coloring configuration via device-tree Date: Mon, 29 Jan 2024 18:18:03 +0100 Message-Id: <20240129171811.21382-8-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Add the "llc-colors" Device Tree attribute to express DomUs and Dom0less color configurations. Based on original work from: Luca Miccio Signed-off-by: Carlo Nonato Signed-off-by: Marco Solieri --- v6: - rewrote domain_set_llc_colors_from_str() to be more explicit v5: - static-mem check has been moved in a previous patch - added domain_set_llc_colors_from_str() to set colors after domain creation --- docs/misc/arm/device-tree/booting.txt | 4 +++ docs/misc/cache-coloring.rst | 48 ++++++++++++++++++++++++++- xen/arch/arm/dom0less-build.c | 11 ++++++ xen/common/llc-coloring.c | 23 +++++++++++++ xen/include/xen/llc-coloring.h | 2 +- 5 files changed, 86 insertions(+), 2 deletions(-) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt index bbd955e9c2..bbe49faadc 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -162,6 +162,10 @@ with the following properties: An integer specifying the number of vcpus to allocate to the guest. +- llc-colors + A string specifying the LLC color configuration for the guest. + Refer to docs/misc/cache_coloring.rst for syntax. + - vpl011 An empty property to enable/disable a virtual pl011 for the guest to diff --git a/docs/misc/cache-coloring.rst b/docs/misc/cache-coloring.rst index c347725525..bf055d7e7f 100644 --- a/docs/misc/cache-coloring.rst +++ b/docs/misc/cache-coloring.rst @@ -10,7 +10,7 @@ If needed, change the maximum number of colors with ``CONFIG_NR_LLC_COLORS=``. Compile Xen and the toolstack and then configure it via -`Command line parameters`_. +`Command line parameters`_. For DomUs follow `DomUs configuration`_. Background ********** @@ -115,6 +115,52 @@ Examples: | 0 | [0] | +-------------------+-----------------------------+ +DomUs configuration +******************* + +DomUs colors can be set via Device Tree, also for Dom0less configurations +(documentation at `docs/misc/arm/device-tree/booting.txt`) using the +``llc-colors`` option. For example: + +:: + + xen,xen-bootargs = "console=dtuart dtuart=serial0 dom0_mem=1G dom0_max_vcpus=1 sched=null llc-coloring=on llc-way-size=64K dom0-llc-colors=2-6"; + xen,dom0-bootargs "console=hvc0 earlycon=xen earlyprintk=xen root=/dev/ram0" + + dom0 { + compatible = "xen,linux-zimage" "xen,multiboot-module"; + reg = <0x0 0x1000000 0x0 15858176>; + }; + + dom0-ramdisk { + compatible = "xen,linux-initrd" "xen,multiboot-module"; + reg = <0x0 0x2000000 0x0 20638062>; + }; + + domU0 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "xen,domain"; + memory = <0x0 0x40000>; + llc-colors = "4-8,10,11,12"; + cpus = <0x1>; + vpl011 = <0x1>; + + module@2000000 { + compatible = "multiboot,kernel", "multiboot,module"; + reg = <0x2000000 0xffffff>; + bootargs = "console=ttyAMA0"; + }; + + module@30000000 { + compatible = "multiboot,ramdisk", "multiboot,module"; + reg = <0x3000000 0xffffff>; + }; + }; + +**Note:** If no color configuration is provided for a domain, the default one, +which corresponds to all available colors is used instead. + Known issues and limitations **************************** diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 992080e61a..efc1bbbc3e 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -807,6 +807,7 @@ void __init create_domUs(void) struct dt_device_node *node; const struct dt_device_node *cpupool_node, *chosen = dt_find_node_by_path("/chosen"); + const char *llc_colors_str = NULL; BUG_ON(chosen == NULL); dt_for_each_child_node(chosen, node) @@ -950,6 +951,11 @@ void __init create_domUs(void) #endif } + dt_property_read_string(node, "llc-colors", &llc_colors_str); + if ( !llc_coloring_enabled && llc_colors_str) + printk(XENLOG_WARNING + "'llc-colors' found, but LLC coloring is disabled\n"); + /* * The variable max_init_domid is initialized with zero, so here it's * very important to use the pre-increment operator to call @@ -960,6 +966,11 @@ void __init create_domUs(void) panic("Error creating domain %s (rc = %ld)\n", dt_node_name(node), PTR_ERR(d)); + if ( llc_coloring_enabled && + (rc = domain_set_llc_colors_from_str(d, llc_colors_str)) ) + panic("Error initializing LLC coloring for domain %s (rc = %d)\n", + dt_node_name(node), rc); + d->is_console = true; dt_device_set_used_by(node, d->domain_id); diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c index aaf0606c00..a932a61e0c 100644 --- a/xen/common/llc-coloring.c +++ b/xen/common/llc-coloring.c @@ -254,6 +254,29 @@ int domain_set_llc_colors_domctl(struct domain *d, return domain_check_colors(d); } +int domain_set_llc_colors_from_str(struct domain *d, const char *str) +{ + int err; + unsigned int *colors; + + if ( !str ) + return domain_set_default_colors(d); + + colors = alloc_colors(max_nr_colors); + if ( !colors ) + return -ENOMEM; + + err = parse_color_config(str, colors, max_nr_colors, &d->num_llc_colors); + if ( err ) + { + printk(XENLOG_ERR "Error parsing LLC color configuration."); + return err; + } + d->llc_colors = colors; + + return domain_check_colors(d); +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/llc-coloring.h b/xen/include/xen/llc-coloring.h index a82081367f..63785c8319 100644 --- a/xen/include/xen/llc-coloring.h +++ b/xen/include/xen/llc-coloring.h @@ -27,7 +27,7 @@ static inline void domain_dump_llc_colors(const struct domain *d) {} unsigned int get_llc_way_size(void); void arch_llc_coloring_init(void); int dom0_set_llc_colors(struct domain *d); - +int domain_set_llc_colors_from_str(struct domain *d, const char *str); int domain_set_llc_colors_domctl(struct domain *d, const struct xen_domctl_set_llc_colors *config); From patchwork Mon Jan 29 17:18:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536092 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 6B300C4828C for ; Mon, 29 Jan 2024 17:19:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673069.1047292 (Exim 4.92) (envelope-from ) id 1rUVI8-0007i9-U2; Mon, 29 Jan 2024 17:19:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673069.1047292; Mon, 29 Jan 2024 17:19:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI8-0007gN-FU; Mon, 29 Jan 2024 17:19:28 +0000 Received: by outflank-mailman (input) for mailman id 673069; Mon, 29 Jan 2024 17:19:27 +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 1rUVI7-0005vb-6Y for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:27 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8cb469f9-beca-11ee-98f5-efadbce2ee36; Mon, 29 Jan 2024 18:19:25 +0100 (CET) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-55a90a0a1a1so2547905a12.0 for ; Mon, 29 Jan 2024 09:19:24 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:23 -0800 (PST) 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: 8cb469f9-beca-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548764; x=1707153564; 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=J9RFmP+aBqqH4SIR3Jn1WqEGTeAcNYfa+alt6ENH+Bw=; b=p0CPUrxvQY5EiTPuTGURNV/dgMauzAM/e1OJKWjfBlKcDHI5bkn2b2QNus8BVPIc2m so0rtl8QgwDRMAda8Jm2hnx8GZXlpzXbg2U48OR40mlrEX1kFTIQH2HaE9ZHGkNcFMBh rQOG4X4SlXImG0g7DpN+OWyfhNxxqy5YDsRz/otA3vXD7wZ8P48+ElOOJfcTgXm8WxTw Cu/kmXUSg6F2jKOwPNFCJ2d3l5TDGYZfsBJNc9ilD1YUc81AxDexa7oUNrXg3N2XfcDc jIeprkldfJogYG4tKYcHBmjCGP/hZvHtS5D3ljzgVTtx/kJstFdDDfhfRD0uEltEa8BF MZww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548764; x=1707153564; 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=J9RFmP+aBqqH4SIR3Jn1WqEGTeAcNYfa+alt6ENH+Bw=; b=V3YmO++8wF8RfeYX0N2R1xDNyinCFTGqf23A3CFSY3vw3DTfPA+DD6CCILqb/fx9R/ RE8WadWQlzTg7L8WzEriTRxPXX9uYsJ9GD7DXls1SKZrzYeaiSFz3eJj+yHIm/WPCrD/ ZE8+qU0hVzLHztffDHMPF9JquTkuE5zEU7PrO5BBUD8m8hBvI228YkZDUiCBzNesPAW2 f2Cbn9We8kGeK+OiXOC+10HNMCEpj/V6dxTgihB6u1maAeB/COGPOfove+yrAIctbb9s fW3pFzy4s70mGuhWCIi0a9ui2eTneCz5TmLujPas1YF1Rj9RN+xPvOKq8fbqIq8V64Ts Yn0Q== X-Gm-Message-State: AOJu0YzSBdELRzDBFzULawDhgMSR4swDtixoVs9u339OzWiCuD2S5NJ0 ogH7tAQiSbK46I9X4n/gjvo+Epy0gCbD1x+hpEXF1GkCQ+1XIAz4TGrwCP+LVi9dIx8NE5ZMQNd QY1o= X-Google-Smtp-Source: AGHT+IHKjEqoRTvmqUd5xzklE7o7VNS35XUcP7U5jcbyKHDOgRixQG2hSX8IN+N4vxxGKn3ZYTeWUQ== X-Received: by 2002:a05:6402:1b10:b0:55d:1eae:1e9f with SMTP id by16-20020a0564021b1000b0055d1eae1e9fmr4327297edb.15.1706548763994; Mon, 29 Jan 2024 09:19:23 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v6 08/15] xen/page_alloc: introduce init_free_page_fields() helper Date: Mon, 29 Jan 2024 18:18:04 +0100 Message-Id: <20240129171811.21382-9-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Introduce a new helper to initialize fields that have different uses for free pages. Signed-off-by: Carlo Nonato Acked-by: Jan Beulich --- v6: - Carlo Nonato as the only signed-off-by v5: - new patch --- xen/common/page_alloc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 2f4f2859c4..2ec17df9b4 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -925,6 +925,13 @@ static struct page_info *get_free_buddy(unsigned int zone_lo, } } +/* Initialise fields which have other uses for free pages. */ +static void init_free_page_fields(struct page_info *pg) +{ + pg->u.inuse.type_info = PGT_TYPE_INFO_INITIALIZER; + page_set_owner(pg, NULL); +} + /* Allocate 2^@order contiguous pages. */ static struct page_info *alloc_heap_pages( unsigned int zone_lo, unsigned int zone_hi, @@ -1033,10 +1040,7 @@ static struct page_info *alloc_heap_pages( accumulate_tlbflush(&need_tlbflush, &pg[i], &tlbflush_timestamp); - /* Initialise fields which have other uses for free pages. */ - pg[i].u.inuse.type_info = PGT_TYPE_INFO_INITIALIZER; - page_set_owner(&pg[i], NULL); - + init_free_page_fields(&pg[i]); } spin_unlock(&heap_lock); @@ -2799,9 +2803,7 @@ static bool prepare_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, * to PGC_state_inuse. */ pg[i].count_info = PGC_static | PGC_state_inuse; - /* Initialise fields which have other uses for free pages. */ - pg[i].u.inuse.type_info = PGT_TYPE_INFO_INITIALIZER; - page_set_owner(&pg[i], NULL); + init_free_page_fields(&pg[i]); } spin_unlock(&heap_lock); From patchwork Mon Jan 29 17:18:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536091 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 74AE1C48290 for ; Mon, 29 Jan 2024 17:19:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673070.1047298 (Exim 4.92) (envelope-from ) id 1rUVI9-0007ns-8k; Mon, 29 Jan 2024 17:19:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673070.1047298; Mon, 29 Jan 2024 17:19:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI8-0007lm-U6; Mon, 29 Jan 2024 17:19:28 +0000 Received: by outflank-mailman (input) for mailman id 673070; Mon, 29 Jan 2024 17:19:28 +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 1rUVI8-0005vb-6o for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:28 +0000 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [2a00:1450:4864:20::22f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8d126f7d-beca-11ee-98f5-efadbce2ee36; Mon, 29 Jan 2024 18:19:25 +0100 (CET) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2cf59087d50so22202321fa.0 for ; Mon, 29 Jan 2024 09:19:25 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:24 -0800 (PST) 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: 8d126f7d-beca-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548765; x=1707153565; 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=qm43AlNShlPAFLpjGrbILKxF1nwMflaP0c3YFoLDGIo=; b=xyQiKwhTkRsgB/haFtAIKE3lX3+5834bFvV+uG98hOo75SvFykk3HMnpfgag9u/DRg aPFv/eWfgVp9QSvK83y+P8nl9/l5dT9ddPfK04MYNNoIxHWDriXcHGVolfmUclnGJd7d 0/U0zfkGjj5ScR1b1srkq2OgMpnme8PN94gh91OCcLEn665aqOOuVdlkInaipThPwHGF xjRFlGh81DqcQiWnAvWgBDpZ2rYYfxt68lyuyrdd6bP0bNCcym92Yw6EwW7KqsHKRxBK jew2rcDUdVR/BOpziIFfer1a8nD6Y1pvS+pktOcXMtUaa/xJpsKKB/06O0VaitySnE4m 5seQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548765; x=1707153565; 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=qm43AlNShlPAFLpjGrbILKxF1nwMflaP0c3YFoLDGIo=; b=pYZ9c1WadYQI67BdgGOHxD0tQ8R65pr9++QhlX6HYLQEo+ltDUESDzbrS9uxQAcBMY vW9tkgwnHov63IY+bd7Y8Pe9o4tULUSA4UjnopAmDdIXGxAimP+mccqeE1J701hnud6p eSr1/4NV8KI0fRP6bTs5mVIUML28q+tqXMi5iThIV4B5P/scyfGHtD1wMX8S0VPVWNa+ S381PJ68KQ3kJCA4rRxmP6XcAZtQOy8TA77x+b+GTY4RiMt7chSfwhiqTi7iKiFnZEP8 KBqg5grUlYQ6/uzjhfC2oc/byeMPKmCh4e/aVxfqjeIjHhBYVTVk3dlac14CyzhaU6bS HbOA== X-Gm-Message-State: AOJu0YxA37RxjLU7QanWUVUJGMCXTG1OXPWx+ilblZFZytYosHOze03V Eryo/dURvxKOcxkQlO5MzbEW+OwvJYTEkb3wcFC1MEuxZHr2EMqYGlxGjSXhleJeZlBt0G1zMbT wgM4= X-Google-Smtp-Source: AGHT+IEMIXCUAhRBg5kbZYAqHRLvcRRw5cqtcSd6LePNjKTjKwemJZQSD3Z1kz79Ll/ztDU8Z+kicw== X-Received: by 2002:a2e:808b:0:b0:2cf:1c9c:a43b with SMTP id i11-20020a2e808b000000b002cf1c9ca43bmr3709564ljg.18.1706548764946; Mon, 29 Jan 2024 09:19:24 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v6 09/15] xen/page_alloc: introduce preserved page flags macro Date: Mon, 29 Jan 2024 18:18:05 +0100 Message-Id: <20240129171811.21382-10-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 PGC_static and PGC_extra are flags that needs to be preserved when assigning a page. Define a new macro that groups those flags and use it instead of or'ing every time. Signed-off-by: Carlo Nonato --- v6: - preserved_flags renamed to PGC_preserved - PGC_preserved is used only in assign_pages() v5: - new patch --- xen/common/page_alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 2ec17df9b4..7c135e0bb4 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -157,6 +157,8 @@ #define PGC_static 0 #endif +#define PGC_preserved (PGC_extra | PGC_static) + #ifndef PGT_TYPE_INFO_INITIALIZER #define PGT_TYPE_INFO_INITIALIZER 0 #endif @@ -2362,7 +2364,7 @@ int assign_pages( for ( i = 0; i < nr; i++ ) { - ASSERT(!(pg[i].count_info & ~(PGC_extra | PGC_static))); + ASSERT(!(pg[i].count_info & ~PGC_preserved)); if ( pg[i].count_info & PGC_extra ) extra_pages++; } @@ -2422,7 +2424,7 @@ int assign_pages( page_set_owner(&pg[i], d); smp_wmb(); /* Domain pointer must be visible before updating refcnt. */ pg[i].count_info = - (pg[i].count_info & (PGC_extra | PGC_static)) | PGC_allocated | 1; + (pg[i].count_info & PGC_preserved) | PGC_allocated | 1; page_list_add_tail(&pg[i], page_to_list(d, &pg[i])); } From patchwork Mon Jan 29 17:18:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536095 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 5B561C48291 for ; Mon, 29 Jan 2024 17:19:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673071.1047302 (Exim 4.92) (envelope-from ) id 1rUVI9-0007u4-Lf; Mon, 29 Jan 2024 17:19:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673071.1047302; Mon, 29 Jan 2024 17:19:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVI9-0007sW-C8; Mon, 29 Jan 2024 17:19:29 +0000 Received: by outflank-mailman (input) for mailman id 673071; Mon, 29 Jan 2024 17:19:28 +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 1rUVI8-0005vY-5J for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:28 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8dded0bd-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:26 +0100 (CET) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-55c33773c0aso2932656a12.1 for ; Mon, 29 Jan 2024 09:19:26 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:25 -0800 (PST) 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: 8dded0bd-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548766; x=1707153566; 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=xs19vJNLniUVsdKVutvtLwP1VZTZPktS4ivl+2Fef/4=; b=IjIGYpjDlCncxLWFRF2+pHvMOZL5A89ZJKpFy5fa2zWwFDPZkdAnsBmVrHn0BgmflY piQ7k15dmALMOVpSuCNmWa4adVYVZQR+U1VVMvCw5JZttBaHOvGjuYZFjVdgRTQN2TdG Zn1anbmczluv8u/g2jnXWIcUw00h/uKL3TbNHOAX9vGO0CKKEExCv9cE8ZNfCE3h9+ML vYss4Rl/u0kKn2M2bXnrbZTLzxEAF8RMK05jQm0IvuBjw8+w0Q806cGLju6HfhGfBk7o WVuSoLCWkK48kzzIGZJJ0Gf+Plwlrkkfn6Lrmjq0EGLLMWuPDsVNb286sQX83SizSKqT worQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548766; x=1707153566; 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=xs19vJNLniUVsdKVutvtLwP1VZTZPktS4ivl+2Fef/4=; b=bWlqd/d5SlUrd62LujEnaKMD2h0Mvra3XGx3jJewYTgpoNn6jSWDeNKzCLfj0FPKJX +ktwk+ezWEYMHntFJfVBrLdOeT0mJQCs/qMUgGjXDbGXLnn6YbOuExmQDFvkRtX3qq0E JDdM6aY9VTXnvgQcgeY20Npz3W88xm3aEGia1GuZ+0+eMiwzuH1e4Fog1emm1Oe69dTk zSSe48+9qr5yHWethw/0/36AOMjPyandqUt8KF2V5Il+nsn9Vf5bNc5yFCP5T5h9SUqd lnV1rUXv4/YEfG5VScM/MxuhUil4zg9I37dAXtUNWGUcb6D4gSlARFHqhiGSxL922qzG qacw== X-Gm-Message-State: AOJu0YzGio4Cot8cwRffRYrvk+mfqCUsifWXdNHcOrw/UEtTkuvePfPh MnH6irzWYS78WT0PmP7IttBvEiH5NnyssD6GnY6XS8eY1pvoH8JYpOqxGYpQ836JgVzB9aD4OCm zBGs= X-Google-Smtp-Source: AGHT+IGdGT5cRny9mU8SBbkRLw3pKeULmlYnq2TZaaLSJz9byCvAP1JqTQcUJfCPT6IILFXDNjoRGA== X-Received: by 2002:a05:6402:40c8:b0:55d:3d64:3ba6 with SMTP id z8-20020a05640240c800b0055d3d643ba6mr5232740edb.29.1706548765751; Mon, 29 Jan 2024 09:19:25 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Marco Solieri Subject: [PATCH v6 10/15] xen: add cache coloring allocator for domains Date: Mon, 29 Jan 2024 18:18:06 +0100 Message-Id: <20240129171811.21382-11-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Add a new memory page allocator that implements the cache coloring mechanism. The allocation algorithm enforces equal frequency distribution of cache partitions, following the coloring configuration of a domain. This allows for an even utilization of cache sets for every domain. Pages are stored in a color-indexed array of lists. Those lists are filled by a simple init function which computes the color of each page. When a domain requests a page, the allocator extract the page from the list with the maximum number of free pages between those that the domain can access, given its coloring configuration. The allocator can only handle requests of order-0 pages. This allows for easier implementation and since cache coloring targets only embedded systems, it's assumed not to be a major problem. The buddy allocator must coexist with the colored one because the Xen heap isn't colored. For this reason a new Kconfig option and a command line parameter are added to let the user set the amount of memory reserved for the buddy allocator. Even when cache coloring is enabled, this memory isn't managed by the colored allocator. Colored heap information is dumped in the dump_heap() debug-key function. Based on original work from: Luca Miccio Signed-off-by: Marco Solieri Signed-off-by: Carlo Nonato --- v6: - colored allocator functions are now static v5: - Carlo Nonato as the new author - the colored allocator balances color usage for each domain and it searches linearly only in the number of colors (FIXME removed) - addedd scrub functionality - removed stub functions (still requires some macro definition) - addr_to_color turned to mfn_to_color for easier operations - removed BUG_ON in init_color_heap_pages() in favor of panic() - only non empty page lists are logged in dump_color_heap() v4: - moved colored allocator code after buddy allocator because it now has some dependencies on buddy functions - buddy_alloc_size is now used only by the colored allocator - fixed a bug that allowed the buddy to merge pages when they were colored - free_color_heap_page() now calls mark_page_free() - free_color_heap_page() uses of the frametable array for faster searches - added FIXME comment for the linear search in free_color_heap_page() - removed alloc_color_domheap_page() to let the colored allocator exploit some more buddy allocator code - alloc_color_heap_page() now allocs min address pages first - reduced the mess in end_boot_allocator(): use the first loop for init_color_heap_pages() - fixed page_list_add_prev() (list.h) since it was doing the opposite of what it was supposed to do - fixed page_list_add_prev() (non list.h) to check also for next existence - removed unused page_list_add_next() - moved p2m code in another patch --- docs/misc/cache-coloring.rst | 37 ++++++ docs/misc/xen-command-line.pandoc | 14 +++ xen/arch/Kconfig | 8 ++ xen/arch/arm/include/asm/mm.h | 5 + xen/common/llc-coloring.c | 13 ++ xen/common/page_alloc.c | 194 +++++++++++++++++++++++++++++- xen/include/xen/llc-coloring.h | 4 + 7 files changed, 270 insertions(+), 5 deletions(-) diff --git a/docs/misc/cache-coloring.rst b/docs/misc/cache-coloring.rst index bf055d7e7f..db1a719698 100644 --- a/docs/misc/cache-coloring.rst +++ b/docs/misc/cache-coloring.rst @@ -9,6 +9,9 @@ To compile LLC coloring support set ``CONFIG_LLC_COLORING=y``. If needed, change the maximum number of colors with ``CONFIG_NR_LLC_COLORS=``. +If needed, change the buddy allocator reserved size with +``CONFIG_BUDDY_ALLOCATOR_SIZE=``. + Compile Xen and the toolstack and then configure it via `Command line parameters`_. For DomUs follow `DomUs configuration`_. @@ -87,6 +90,8 @@ More specific documentation is available at `docs/misc/xen-command-line.pandoc`. +----------------------+-------------------------------+ | ``dom0-llc-colors`` | Dom0 color configuration | +----------------------+-------------------------------+ +| ``buddy-alloc-size`` | Buddy allocator reserved size | ++----------------------+-------------------------------+ Colors selection format *********************** @@ -161,6 +166,17 @@ DomUs colors can be set via Device Tree, also for Dom0less configurations **Note:** If no color configuration is provided for a domain, the default one, which corresponds to all available colors is used instead. +Colored allocator and buddy allocator +************************************* + +The colored allocator distributes pages based on color configurations of +domains so that each domains only gets pages of its own colors. +The colored allocator is meant as an alternative to the buddy allocator because +its allocation policy is by definition incompatible with the generic one. Since +the Xen heap is not colored yet, we need to support the coexistence of the two +allocators and some memory must be left for the buddy one. Buddy memory +reservation is configured via Kconfig or via command-line. + Known issues and limitations **************************** @@ -171,3 +187,24 @@ In the domain configuration, "xen,static-mem" allows memory to be statically allocated to the domain. This isn't possible when LLC coloring is enabled, because that memory can't be guaranteed to use only colors assigned to the domain. + +Cache coloring is intended only for embedded systems +#################################################### + +The current implementation aims to satisfy the need of predictability in +embedded systems with small amount of memory to be managed in a colored way. +Given that, some shortcuts are taken in the development. Expect worse +performances on larger systems. + +Colored allocator can only make use of order-0 pages +#################################################### + +The cache coloring technique relies on memory mappings and on the smallest +amount of memory that can be mapped to achieve the maximum number of colors +(cache partitions) possible. This amount is what is normally called a page and, +in Xen terminology, the order-0 page is the smallest one. The fairly simple +colored allocator currently implemented, makes use only of such pages. +It must be said that a more complex one could, in theory, adopt higher order +pages if the colors selection contained adjacent colors. Two subsequent colors, +for example, can be represented by an order-1 page, four colors correspond to +an order-2 page, etc. diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 25da997b5b..d52d38b97a 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -270,6 +270,20 @@ and not running softirqs. Reduce this if softirqs are not being run frequently enough. Setting this to a high value may cause boot failure, particularly if the NMI watchdog is also enabled. +### buddy-alloc-size (arm64) +> `= ` + +> Default: `64M` + +Amount of memory reserved for the buddy allocator when colored allocator is +active. This options is parsed only when LLC coloring support is enabled. +The colored allocator is meant as an alternative to the buddy allocator, +because its allocation policy is by definition incompatible with the generic +one. Since the Xen heap systems is not colored yet, we need to support the +coexistence of the two allocators for now. This parameter, which is optional +and for expert only, it's used to set the amount of memory reserved to the +buddy allocator. + ### cet = List of [ shstk=, ibt= ] diff --git a/xen/arch/Kconfig b/xen/arch/Kconfig index c1157bcbcb..b50082eb84 100644 --- a/xen/arch/Kconfig +++ b/xen/arch/Kconfig @@ -48,3 +48,11 @@ config NR_LLC_COLORS bound. The runtime value is autocomputed or manually set via cmdline. The default value corresponds to an 8 MiB 16-ways LLC, which should be more than what needed in the general case. + +config BUDDY_ALLOCATOR_SIZE + int "Buddy allocator reserved memory size (MiB)" + default "64" + depends on LLC_COLORING + help + Amount of memory reserved for the buddy allocator to serve Xen heap, + working alongside the colored one. diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h index cbcf3bf147..1829c559d6 100644 --- a/xen/arch/arm/include/asm/mm.h +++ b/xen/arch/arm/include/asm/mm.h @@ -145,6 +145,11 @@ struct page_info #else #define PGC_static 0 #endif +#ifdef CONFIG_LLC_COLORING +/* Page is cache colored */ +#define _PGC_colored PG_shift(4) +#define PGC_colored PG_mask(1, 4) +#endif /* ... */ /* Page is broken? */ #define _PGC_broken PG_shift(7) diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c index a932a61e0c..25e0861733 100644 --- a/xen/common/llc-coloring.c +++ b/xen/common/llc-coloring.c @@ -21,6 +21,9 @@ static unsigned int __ro_after_init max_nr_colors = CONFIG_NR_LLC_COLORS; static unsigned int __initdata dom0_colors[CONFIG_NR_LLC_COLORS]; static unsigned int __initdata dom0_num_colors; +#define mfn_color_mask (max_nr_colors - 1) +#define mfn_to_color(mfn) (mfn_x(mfn) & mfn_color_mask) + /* * Parse the coloring configuration given in the buf string, following the * syntax below. @@ -277,6 +280,16 @@ int domain_set_llc_colors_from_str(struct domain *d, const char *str) return domain_check_colors(d); } +unsigned int page_to_llc_color(const struct page_info *pg) +{ + return mfn_to_color(page_to_mfn(pg)); +} + +unsigned int get_max_nr_llc_colors(void) +{ + return max_nr_colors; +} + /* * Local variables: * mode: C diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 7c135e0bb4..469d78869f 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -126,6 +126,7 @@ #include #include #include +#include #include #include #include @@ -157,7 +158,11 @@ #define PGC_static 0 #endif -#define PGC_preserved (PGC_extra | PGC_static) +#ifndef PGC_colored +#define PGC_colored 0 +#endif + +#define PGC_preserved (PGC_extra | PGC_static | PGC_colored) #ifndef PGT_TYPE_INFO_INITIALIZER #define PGT_TYPE_INFO_INITIALIZER 0 @@ -1504,6 +1509,7 @@ static void free_heap_pages( if ( !mfn_valid(page_to_mfn(predecessor)) || !page_state_is(predecessor, free) || (predecessor->count_info & PGC_static) || + (predecessor->count_info & PGC_colored) || (PFN_ORDER(predecessor) != order) || (page_to_nid(predecessor) != node) ) break; @@ -1528,6 +1534,7 @@ static void free_heap_pages( if ( !mfn_valid(page_to_mfn(successor)) || !page_state_is(successor, free) || (successor->count_info & PGC_static) || + (successor->count_info & PGC_colored) || (PFN_ORDER(successor) != order) || (page_to_nid(successor) != node) ) break; @@ -1943,6 +1950,161 @@ static unsigned long avail_heap_pages( return free_pages; } +/************************* + * COLORED SIDE-ALLOCATOR + * + * Pages are grouped by LLC color in lists which are globally referred to as the + * color heap. Lists are populated in end_boot_allocator(). + * After initialization there will be N lists where N is the number of + * available colors on the platform. + */ +static struct page_list_head *__ro_after_init _color_heap; +static unsigned long *__ro_after_init free_colored_pages; + +/* Memory required for buddy allocator to work with colored one */ +#ifdef CONFIG_LLC_COLORING +static unsigned long __initdata buddy_alloc_size = + MB(CONFIG_BUDDY_ALLOCATOR_SIZE); +size_param("buddy-alloc-size", buddy_alloc_size); + +#define domain_num_llc_colors(d) (d)->num_llc_colors +#define domain_llc_color(d, i) (d)->llc_colors[(i)] +#else +static unsigned long __initdata buddy_alloc_size; + +#define domain_num_llc_colors(d) 0 +#define domain_llc_color(d, i) 0 +#endif + +#define color_heap(color) (&_color_heap[color]) + +static void free_color_heap_page(struct page_info *pg, bool need_scrub) +{ + unsigned int color = page_to_llc_color(pg); + struct page_list_head *head = color_heap(color); + + spin_lock(&heap_lock); + + mark_page_free(pg, page_to_mfn(pg)); + + if ( need_scrub ) + { + pg->count_info |= PGC_need_scrub; + poison_one_page(pg); + } + + pg->count_info |= PGC_colored; + free_colored_pages[color]++; + page_list_add(pg, head); + + spin_unlock(&heap_lock); +} + +static struct page_info *alloc_color_heap_page(unsigned int memflags, + const struct domain *d) +{ + struct page_info *pg = NULL; + unsigned int i, color = 0; + unsigned long max = 0; + bool need_tlbflush = false; + uint32_t tlbflush_timestamp = 0; + bool scrub = !(memflags & MEMF_no_scrub); + + spin_lock(&heap_lock); + + for ( i = 0; i < domain_num_llc_colors(d); i++ ) + { + unsigned long free = free_colored_pages[domain_llc_color(d, i)]; + + if ( free > max ) + { + color = domain_llc_color(d, i); + pg = page_list_first(color_heap(color)); + max = free; + } + } + + if ( !pg ) + { + spin_unlock(&heap_lock); + return NULL; + } + + pg->count_info = PGC_state_inuse | PGC_colored | + (pg->count_info & PGC_need_scrub); + free_colored_pages[color]--; + page_list_del(pg, color_heap(color)); + + if ( !(memflags & MEMF_no_tlbflush) ) + accumulate_tlbflush(&need_tlbflush, pg, &tlbflush_timestamp); + + init_free_page_fields(pg); + + spin_unlock(&heap_lock); + + if ( test_and_clear_bit(_PGC_need_scrub, &pg->count_info) && scrub ) + scrub_one_page(pg); + else if ( scrub ) + check_one_page(pg); + + if ( need_tlbflush ) + filtered_flush_tlb_mask(tlbflush_timestamp); + + flush_page_to_ram(mfn_x(page_to_mfn(pg)), + !(memflags & MEMF_no_icache_flush)); + + return pg; +} + +static void __init init_color_heap_pages(struct page_info *pg, + unsigned long nr_pages) +{ + unsigned int i; + bool need_scrub = opt_bootscrub == BOOTSCRUB_IDLE; + + if ( buddy_alloc_size ) + { + unsigned long buddy_pages = min(PFN_DOWN(buddy_alloc_size), nr_pages); + + init_heap_pages(pg, buddy_pages); + nr_pages -= buddy_pages; + buddy_alloc_size -= buddy_pages << PAGE_SHIFT; + pg += buddy_pages; + } + + if ( !_color_heap ) + { + unsigned int max_nr_colors = get_max_nr_llc_colors(); + + _color_heap = xmalloc_array(struct page_list_head, max_nr_colors); + free_colored_pages = xzalloc_array(unsigned long, max_nr_colors); + if ( !_color_heap || !free_colored_pages ) + panic("Can't allocate colored heap. Buddy reserved size is too low"); + + for ( i = 0; i < max_nr_colors; i++ ) + INIT_PAGE_LIST_HEAD(color_heap(i)); + } + + if ( nr_pages ) + printk(XENLOG_DEBUG + "Init color heap with %lu pages, start MFN: %"PRI_mfn"\n", + nr_pages, mfn_x(page_to_mfn(pg))); + + for ( i = 0; i < nr_pages; i++ ) + free_color_heap_page(&pg[i], need_scrub); +} + +static void dump_color_heap(void) +{ + unsigned int color; + + printk("Dumping color heap info\n"); + for ( color = 0; color < get_max_nr_llc_colors(); color++ ) + if ( free_colored_pages[color] > 0 ) + printk("Color heap[%u]: %lu pages\n", + color, free_colored_pages[color]); +} + void __init end_boot_allocator(void) { unsigned int i; @@ -1962,7 +2124,13 @@ void __init end_boot_allocator(void) for ( i = nr_bootmem_regions; i-- > 0; ) { struct bootmem_region *r = &bootmem_region_list[i]; - if ( r->s < r->e ) + + if ( r->s >= r->e ) + continue; + + if ( llc_coloring_enabled ) + init_color_heap_pages(mfn_to_page(_mfn(r->s)), r->e - r->s); + else init_heap_pages(mfn_to_page(_mfn(r->s)), r->e - r->s); } nr_bootmem_regions = 0; @@ -2458,7 +2626,14 @@ struct page_info *alloc_domheap_pages( if ( memflags & MEMF_no_owner ) memflags |= MEMF_no_refcount; - if ( !dma_bitsize ) + /* Only domains are supported for coloring */ + if ( d && llc_coloring_enabled ) + { + /* Colored allocation must be done on 0 order */ + if ( order || (pg = alloc_color_heap_page(memflags, d)) == NULL ) + return NULL; + } + else if ( !dma_bitsize ) memflags &= ~MEMF_no_dma; else if ( (dma_zone = bits_to_zone(dma_bitsize)) < zone_hi ) pg = alloc_heap_pages(dma_zone + 1, zone_hi, order, memflags, d); @@ -2483,7 +2658,10 @@ struct page_info *alloc_domheap_pages( } if ( assign_page(pg, order, d, memflags) ) { - free_heap_pages(pg, order, memflags & MEMF_no_scrub); + if ( pg->count_info & PGC_colored ) + free_color_heap_page(pg, memflags & MEMF_no_scrub); + else + free_heap_pages(pg, order, memflags & MEMF_no_scrub); return NULL; } } @@ -2566,7 +2744,10 @@ void free_domheap_pages(struct page_info *pg, unsigned int order) scrub = 1; } - free_heap_pages(pg, order, scrub); + if ( pg->count_info & PGC_colored ) + free_color_heap_page(pg, scrub); + else + free_heap_pages(pg, order, scrub); } if ( drop_dom_ref ) @@ -2673,6 +2854,9 @@ static void cf_check dump_heap(unsigned char key) continue; printk("Node %d has %lu unscrubbed pages\n", i, node_need_scrub[i]); } + + if ( llc_coloring_enabled ) + dump_color_heap(); } static __init int cf_check register_heap_trigger(void) diff --git a/xen/include/xen/llc-coloring.h b/xen/include/xen/llc-coloring.h index 63785c8319..b96a7134ed 100644 --- a/xen/include/xen/llc-coloring.h +++ b/xen/include/xen/llc-coloring.h @@ -31,6 +31,10 @@ int domain_set_llc_colors_from_str(struct domain *d, const char *str); int domain_set_llc_colors_domctl(struct domain *d, const struct xen_domctl_set_llc_colors *config); +struct page_info; +unsigned int page_to_llc_color(const struct page_info *pg); +unsigned int get_max_nr_llc_colors(void); + #endif /* __COLORING_H__ */ /* From patchwork Mon Jan 29 17:18:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536094 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 CA460C48293 for ; Mon, 29 Jan 2024 17:19:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673072.1047319 (Exim 4.92) (envelope-from ) id 1rUVIB-0008VC-Qg; Mon, 29 Jan 2024 17:19:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673072.1047319; Mon, 29 Jan 2024 17:19:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVIB-0008Rh-H4; Mon, 29 Jan 2024 17:19:31 +0000 Received: by outflank-mailman (input) for mailman id 673072; Mon, 29 Jan 2024 17:19:29 +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 1rUVI9-0005vb-BV for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:29 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8e6fcc91-beca-11ee-98f5-efadbce2ee36; Mon, 29 Jan 2024 18:19:27 +0100 (CET) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-55eece07a75so1848389a12.2 for ; Mon, 29 Jan 2024 09:19:27 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:26 -0800 (PST) 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: 8e6fcc91-beca-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548767; x=1707153567; 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=7UdP4nrilFTONRQo3Q1Leq4bZtPWA15sZcG7JE/zaUg=; b=Z6P6erqAeozayEiMEQuSDBbZB4fcXfRASweNbgwO8xi7YHnrrD1radBwEybaMhcAql luWqdFll0VhN3+nUklb70vT9i8WpXzWzu29wJP9uYfFDh3B3CP1oy6P4BQZn9JumOqa4 d33KjxrGc0vh/tdHlQBY4EcxfM7BsCjNkPr9qOENkZdxyP5SiqpfMmxXfOQev1wFOZcZ ERp2ueS+hF7qdZRNFHxvtdhu92xMPZNApsFq/12/o065w8Me2RfFbi5CW3HSkARll+Od GqwnSO6xtaQBXe/LzAx/b8HzgOmEJOLVDOj4Q4mC/E7QrBA8vPYSIbbepkBPhKCbFplz FHfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548767; x=1707153567; 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=7UdP4nrilFTONRQo3Q1Leq4bZtPWA15sZcG7JE/zaUg=; b=gOuHNWemvAg+9wRjAZCMC3EHO9QV45kbiT1Mh8pzngd9/xssBdyIj294upHaohmE8o 6UJDH1yGmETIz6Y8J/41ifd12omHMDN4wqlIl1PgEeksBYOh2yZ6LLHUhmkIsMqwIGu7 pr/Y9A5msNg9BfLy5BnbbufvbBw4m531k+5DiGpCqyZIl4LXFaIlPzkbVyvoc4vsmJtw F2dNxIEirVFwgy09cB9ITOLdlXTKFVaozhT8QeLz9Q9jDH1FBsGz9Bp/BGgZRPPD7o9X 0qTEcj+kpx4ozEy202AUp5cfEvJEbYqNOEhSz79nlOvSfZ7yS1lk0csQB+x68WAKOBkQ AWpQ== X-Gm-Message-State: AOJu0Yzckt1gLBcFw/klIYdG3wWkbwgSBfAXRukc3jxLE9XejH0W2Oy0 wb7y/hmT+Pb0dgpd8qI6NxtXAqfOOJNi9GK7gBvOfrpculrdjdYVzs4qhxmLmoNGDJtg/Rj+OQh szKw= X-Google-Smtp-Source: AGHT+IGCV8RaY9mKxLFe87VSIFwQXw7gaXAqUqjMDarSQiLKN1CM0EMIwpP8Z/6WHnQWIpAd/I790Q== X-Received: by 2002:a05:6402:524c:b0:55e:ee3a:723 with SMTP id t12-20020a056402524c00b0055eee3a0723mr2972287edd.12.1706548766905; Mon, 29 Jan 2024 09:19:26 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v6 11/15] xen/arm: use domain memory to allocate p2m page tables Date: Mon, 29 Jan 2024 18:18:07 +0100 Message-Id: <20240129171811.21382-12-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Cache colored domains can benefit from having p2m page tables allocated with the same coloring schema so that isolation can be achieved also for those kind of memory accesses. In order to do that, the domain struct is passed to the allocator and the MEMF_no_owner flag is used. This will be useful also when NUMA will be supported on Arm. Signed-off-by: Carlo Nonato Acked-by: Julien Grall --- v6: - Carlo Nonato as the only signed-off-by v5: - new patch --- xen/arch/arm/mmu/p2m.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c index 41fcca011c..d02a478cb8 100644 --- a/xen/arch/arm/mmu/p2m.c +++ b/xen/arch/arm/mmu/p2m.c @@ -32,7 +32,7 @@ static struct page_info *p2m_alloc_page(struct domain *d) */ if ( is_hardware_domain(d) ) { - pg = alloc_domheap_page(NULL, 0); + pg = alloc_domheap_page(d, MEMF_no_owner); if ( pg == NULL ) printk(XENLOG_G_ERR "Failed to allocate P2M pages for hwdom.\n"); } @@ -81,7 +81,7 @@ int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preempted) if ( d->arch.paging.p2m_total_pages < pages ) { /* Need to allocate more memory from domheap */ - pg = alloc_domheap_page(NULL, 0); + pg = alloc_domheap_page(d, MEMF_no_owner); if ( pg == NULL ) { printk(XENLOG_ERR "Failed to allocate P2M pages.\n"); From patchwork Mon Jan 29 17:18:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536087 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 9F4B2C48285 for ; Mon, 29 Jan 2024 17:19:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673073.1047326 (Exim 4.92) (envelope-from ) id 1rUVIC-0000Bk-Ll; Mon, 29 Jan 2024 17:19:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673073.1047326; Mon, 29 Jan 2024 17:19:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVIC-00009f-5b; Mon, 29 Jan 2024 17:19:32 +0000 Received: by outflank-mailman (input) for mailman id 673073; Mon, 29 Jan 2024 17:19:29 +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 1rUVI9-0005vY-FN for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:29 +0000 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [2a00:1450:4864:20::52f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8effc653-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:28 +0100 (CET) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-55c2c90c67dso3037320a12.1 for ; Mon, 29 Jan 2024 09:19:28 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:27 -0800 (PST) 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: 8effc653-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548768; x=1707153568; 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=0+y6eeYNyMDcSQ1B2g6r23A3/4HXzjPsqAidl0fgzB0=; b=jCQJR1Y70S1Rwq78IJw45VxIymXcXBu3OEAkBsMrDaKD/lWcPUUKV73bCp6YdhoL2L vbV9RN59oi4VCwfJF4iForykkbvCQPQqJ6XhcXfWagkvjeKv30v0LbbT4N+26Q0APnsJ iBLUCDoK4CBGs6pwoRqP+Zoujd+0q13GZmjdHkY2toP1F76nktKMiACiG+FeEdrHNtTv ZkJAXGpa11tYXIHP7njziGPNKnZxLlwz4HTRu4OTl4F/OaHOt/ZPPRrXLB5rsWdLg8vc RWi6rMBgkEJ8cZRNk+7wcTTOrisrEu8om3csJ7CLaZudp5XRtm8CkNbJOKZcXOab4/FG 7dfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548768; x=1707153568; 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=0+y6eeYNyMDcSQ1B2g6r23A3/4HXzjPsqAidl0fgzB0=; b=Xg1T4KBgnfbOk6iihSa+UqB1W+KUp84ombp+eHygqMpX3pmTls5A1PX4XVgqzyFCve cY/NrtVJaMfusxRYuoIj8QvNnm0K5qnRtKk6zsCZRDUSvo844Ngk4q8kppY9wPH78rg4 tk4MRjkY+rhFioA4b839ffbbqbb3xxrdM3C9DNYuJWlCZ6gkUhnYllslAiNqLIg2hMqv 1PgqacOSkLsUFwsGS3zxxlikZOJ7pT5vpBZztormQ1Wj3fNECcnQOWwMjA1TRHj8Lk8h c8tAh6dhblKChytD5W7hc35ATD8VHUO8ND9a+vpfii2cS2WSMPVQ5GXyOAxemdusrgyH 9x0w== X-Gm-Message-State: AOJu0YxiYWzHMTYU3pvzqZrnMJsULZojNJgdgFcoLJTEj5p8deWPFzDV d3zlrUxzy4WQtmbwyFVLencXhdkgZ09+vZVHpWZPeC/tnaYeJLV0ej1DbjiC/3f1xW++qMnAjT1 DZBs= X-Google-Smtp-Source: AGHT+IEI0GWlrodDNe0XQ3RXAMWNHoRmW/litoKg62TwP7wpr4XGruDNLNLR5Mz7/13p7Z4pZQdQGA== X-Received: by 2002:aa7:d30c:0:b0:55e:e9f3:4f63 with SMTP id p12-20020aa7d30c000000b0055ee9f34f63mr2758139edq.3.1706548767846; Mon, 29 Jan 2024 09:19:27 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Luca Miccio , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Marco Solieri , Carlo Nonato Subject: [PATCH v6 12/15] xen/arm: add Xen cache colors command line parameter Date: Mon, 29 Jan 2024 18:18:08 +0100 Message-Id: <20240129171811.21382-13-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 From: Luca Miccio Add a new command line parameter to configure Xen cache colors. These colors can be dumped with the cache coloring info debug-key. By default, Xen uses the first color. Benchmarking the VM interrupt response time provides an estimation of LLC usage by Xen's most latency-critical runtime task. Results on Arm Cortex-A53 on Xilinx Zynq UltraScale+ XCZU9EG show that one color, which reserves 64 KiB of L2, is enough to attain best responsiveness: - Xen 1 color latency: 3.1 us - Xen 2 color latency: 3.1 us More colors are instead very likely to be needed on processors whose L1 cache is physically-indexed and physically-tagged, such as Cortex-A57. In such cases, coloring applies to L1 also, and there typically are two distinct L1-colors. Therefore, reserving only one color for Xen would senselessly partitions a cache memory that is already private, i.e. underutilize it. The default amount of Xen colors is thus set to one. Signed-off-by: Luca Miccio Signed-off-by: Marco Solieri Signed-off-by: Carlo Nonato --- docs/misc/xen-command-line.pandoc | 10 ++++++++++ xen/common/llc-coloring.c | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index d52d38b97a..8c2b799f1e 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2876,6 +2876,16 @@ mode. **WARNING: `x2apic_phys` is deprecated and superseded by `x2apic-mode`. The latter takes precedence if both are set.** +### xen-llc-colors (arm64) +> `= List of [ | - ]` + +> Default: `0: the lowermost color` + +Specify Xen LLC color configuration. This options is available only when +`CONFIG_LLC_COLORING` is enabled. +Two colors are most likely needed on platforms where private caches are +physically indexed, e.g. the L1 instruction cache of the Arm Cortex-A57. + ### xenheap_megabytes (arm32) > `= ` diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c index 25e0861733..dace881b55 100644 --- a/xen/common/llc-coloring.c +++ b/xen/common/llc-coloring.c @@ -9,6 +9,9 @@ #include #include +#define XEN_DEFAULT_COLOR 0 +#define XEN_DEFAULT_NUM_COLORS 1 + bool __ro_after_init llc_coloring_enabled; boolean_param("llc-coloring", llc_coloring_enabled); @@ -21,6 +24,9 @@ static unsigned int __ro_after_init max_nr_colors = CONFIG_NR_LLC_COLORS; static unsigned int __initdata dom0_colors[CONFIG_NR_LLC_COLORS]; static unsigned int __initdata dom0_num_colors; +static unsigned int __ro_after_init xen_colors[CONFIG_NR_LLC_COLORS]; +static unsigned int __ro_after_init xen_num_colors; + #define mfn_color_mask (max_nr_colors - 1) #define mfn_to_color(mfn) (mfn_x(mfn) & mfn_color_mask) @@ -78,6 +84,12 @@ static int __init parse_dom0_colors(const char *s) } custom_param("dom0-llc-colors", parse_dom0_colors); +static int __init parse_xen_colors(const char *s) +{ + return parse_color_config(s, xen_colors, max_nr_colors, &xen_num_colors); +} +custom_param("xen-llc-colors", parse_xen_colors); + static void print_colors(const unsigned int *colors, unsigned int num_colors) { unsigned int i; @@ -106,6 +118,8 @@ static void dump_coloring_info(unsigned char key) printk("'%c' pressed -> dumping LLC coloring general info\n", key); printk("LLC way size: %u KiB\n", llc_way_size >> 10); printk("Number of LLC colors supported: %u\n", max_nr_colors); + printk("Xen has %u LLC colors: ", xen_num_colors); + print_colors(xen_colors, xen_num_colors); } static bool check_colors(const unsigned int *colors, unsigned int num_colors) @@ -149,6 +163,18 @@ void __init llc_coloring_init(void) panic("Number of LLC colors (%u) not in range [2, %u]\n", max_nr_colors, CONFIG_NR_LLC_COLORS); + if ( !xen_num_colors ) + { + printk(XENLOG_WARNING + "Xen LLC color config not found. Using default color: %u\n", + XEN_DEFAULT_COLOR); + xen_colors[0] = XEN_DEFAULT_COLOR; + xen_num_colors = XEN_DEFAULT_NUM_COLORS; + } + + if ( !check_colors(xen_colors, xen_num_colors) ) + panic("Bad LLC color config for Xen\n"); + register_keyhandler('K', dump_coloring_info, "dump LLC coloring info", 1); arch_llc_coloring_init(); From patchwork Mon Jan 29 17:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536097 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 BBA7FC47DB3 for ; Mon, 29 Jan 2024 17:19:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673074.1047333 (Exim 4.92) (envelope-from ) id 1rUVID-0000Oi-TN; Mon, 29 Jan 2024 17:19:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673074.1047333; Mon, 29 Jan 2024 17:19:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVID-0000Lh-6s; Mon, 29 Jan 2024 17:19:33 +0000 Received: by outflank-mailman (input) for mailman id 673074; Mon, 29 Jan 2024 17:19:31 +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 1rUVIB-0005vb-Bh for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:31 +0000 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [2a00:1450:4864:20::22a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8f8c7d97-beca-11ee-98f5-efadbce2ee36; Mon, 29 Jan 2024 18:19:29 +0100 (CET) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2cc9fa5e8e1so32885801fa.3 for ; Mon, 29 Jan 2024 09:19:29 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:28 -0800 (PST) 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: 8f8c7d97-beca-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548769; x=1707153569; 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=bOEDeXZz+KvpHcMcDfWEFx1e9GAnCTEDaLyDCycF2TQ=; b=QNfB12m7vO4Nj6rT1oA8yx7qRTiEua4Mnk8pc1zyRObZFRpUj0MS7XZmuOmM5eIcEc Rstvt63cyP8I/yHiKIxLd/SP2ZFU5pRGN9y7bIxd9GKxL+zjZI7M3k6ZoA/eXC4PBtOM wNl04us+Ipm4p1tZyMaB6cRyb9eIcp9JbOaLAnsFYNHz7I0Oq9VvjOmJbcjMnRg6anRx hyccWtDUhvEbmJB/0mQgfQVR07xYGeHO+Ua56CbrB7Ddu4Sgnljw8bGAbsdk3tJc+36Z cN9RucFEQ9ZyQmDeN3dGzEjCmJ/HS+kK1Y9W2e9nSYqg06plnum3uZvJiQI0FBghXkdL kCgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548769; x=1707153569; 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=bOEDeXZz+KvpHcMcDfWEFx1e9GAnCTEDaLyDCycF2TQ=; b=aW4AJXEgSsM+XvVPNWvkrv5ZMUi5sxdESNUxviLFUU1P5aEWmGZcATPJxzhfmoPUpx ioTiDuCD6dyBk39wrFOfFYEEDHRsYFFQwmzBnGn1P3Hwoj5aWFAnqeNLIPJ91z6qF9X4 +cpL3cHszhaRsKEH1dsSRt8+Cf94SCCrElrKeUikf82MipJ9bRhNvyxSt58bYsoB8CnT rMeaqC62hjtBV+sDhHxDg+MGGNYMfYkILnOx/Wi5L0op7SDl9bGarav2Dfv10+CvFkAN 96nRt6dLdIevvLPdaekbIcUgoHR5Hf2Ks3B93sWHIHiOkbjI6zVyK87WYLmP9X8r4/dk qc/A== X-Gm-Message-State: AOJu0YxZ53/FCNDAPDBD+bumUiW6HaSzZzeENpA4GM2a9wgqb8wBWt67 5KZyQjL78efwKnSoHO7hPETRa0vlNicQA/djXA1cwzATdIhthSw3ppoVr0FzOk5zhbfX8DinXV8 QjD0= X-Google-Smtp-Source: AGHT+IEHbmtrPBuSoOGAvYNewKRuZ2nMFc2QPdwPS0snVlLI1HqtmRWiBozo33nTOPw6ibBWT4OnRw== X-Received: by 2002:a2e:bc86:0:b0:2cf:f748:1aba with SMTP id h6-20020a2ebc86000000b002cff7481abamr5146953ljf.20.1706548769042; Mon, 29 Jan 2024 09:19:29 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v6 13/15] xen/arm: make consider_modules() available for xen relocation Date: Mon, 29 Jan 2024 18:18:09 +0100 Message-Id: <20240129171811.21382-14-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Cache coloring must physically relocate Xen in order to color the hypervisor and consider_modules() is a key function that is needed to find a new available physical address. 672d67f339c0 ("xen/arm: Split MMU-specific setup_mm() and related code out") moved consider_modules() under arm32. Move it back to setup.c and make it non-static so that it can be used outside. Signed-off-by: Carlo Nonato --- v6: - new patch --- xen/arch/arm/arm32/mmu/mm.c | 93 +------------------------------- xen/arch/arm/include/asm/setup.h | 3 ++ xen/arch/arm/setup.c | 92 +++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 92 deletions(-) diff --git a/xen/arch/arm/arm32/mmu/mm.c b/xen/arch/arm/arm32/mmu/mm.c index cb441ca87c..e9e1e48f9f 100644 --- a/xen/arch/arm/arm32/mmu/mm.c +++ b/xen/arch/arm/arm32/mmu/mm.c @@ -7,6 +7,7 @@ #include #include #include +#include static unsigned long opt_xenheap_megabytes __initdata; integer_param("xenheap_megabytes", opt_xenheap_megabytes); @@ -29,98 +30,6 @@ static void __init setup_directmap_mappings(unsigned long base_mfn, directmap_virt_end = XENHEAP_VIRT_START + nr_mfns * PAGE_SIZE; } -/* - * Returns the end address of the highest region in the range s..e - * with required size and alignment that does not conflict with the - * modules from first_mod to nr_modules. - * - * For non-recursive callers first_mod should normally be 0 (all - * modules and Xen itself) or 1 (all modules but not Xen). - */ -static paddr_t __init consider_modules(paddr_t s, paddr_t e, - uint32_t size, paddr_t align, - int first_mod) -{ - const struct bootmodules *mi = &bootinfo.modules; - int i; - int nr; - - s = (s+align-1) & ~(align-1); - e = e & ~(align-1); - - if ( s > e || e - s < size ) - return 0; - - /* First check the boot modules */ - for ( i = first_mod; i < mi->nr_mods; i++ ) - { - paddr_t mod_s = mi->module[i].start; - paddr_t mod_e = mod_s + mi->module[i].size; - - if ( s < mod_e && mod_s < e ) - { - mod_e = consider_modules(mod_e, e, size, align, i+1); - if ( mod_e ) - return mod_e; - - return consider_modules(s, mod_s, size, align, i+1); - } - } - - /* Now check any fdt reserved areas. */ - - nr = fdt_num_mem_rsv(device_tree_flattened); - - for ( ; i < mi->nr_mods + nr; i++ ) - { - paddr_t mod_s, mod_e; - - if ( fdt_get_mem_rsv_paddr(device_tree_flattened, - i - mi->nr_mods, - &mod_s, &mod_e ) < 0 ) - /* If we can't read it, pretend it doesn't exist... */ - continue; - - /* fdt_get_mem_rsv_paddr returns length */ - mod_e += mod_s; - - if ( s < mod_e && mod_s < e ) - { - mod_e = consider_modules(mod_e, e, size, align, i+1); - if ( mod_e ) - return mod_e; - - return consider_modules(s, mod_s, size, align, i+1); - } - } - - /* - * i is the current bootmodule we are evaluating, across all - * possible kinds of bootmodules. - * - * When retrieving the corresponding reserved-memory addresses, we - * need to index the bootinfo.reserved_mem bank starting from 0, and - * only counting the reserved-memory modules. Hence, we need to use - * i - nr. - */ - nr += mi->nr_mods; - for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) - { - paddr_t r_s = bootinfo.reserved_mem.bank[i - nr].start; - paddr_t r_e = r_s + bootinfo.reserved_mem.bank[i - nr].size; - - if ( s < r_e && r_s < e ) - { - r_e = consider_modules(r_e, e, size, align, i + 1); - if ( r_e ) - return r_e; - - return consider_modules(s, r_s, size, align, i + 1); - } - } - return e; -} - /* * Find a contiguous region that fits in the static heap region with * required size and alignment, and return the end address of the region diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h index d15a88d2e0..37c0e345f0 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -207,6 +207,9 @@ struct init_info unsigned int cpuid; }; +paddr_t consider_modules(paddr_t s, paddr_t e, uint32_t size, paddr_t align, + int first_mod); + #endif /* * Local variables: diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 14cb023783..28f4761705 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -545,6 +545,98 @@ static void * __init relocate_fdt(paddr_t dtb_paddr, size_t dtb_size) return fdt; } +/* + * Returns the end address of the highest region in the range s..e + * with required size and alignment that does not conflict with the + * modules from first_mod to nr_modules. + * + * For non-recursive callers first_mod should normally be 0 (all + * modules and Xen itself) or 1 (all modules but not Xen). + */ +paddr_t __init consider_modules(paddr_t s, paddr_t e, + uint32_t size, paddr_t align, + int first_mod) +{ + const struct bootmodules *mi = &bootinfo.modules; + int i; + int nr; + + s = (s+align-1) & ~(align-1); + e = e & ~(align-1); + + if ( s > e || e - s < size ) + return 0; + + /* First check the boot modules */ + for ( i = first_mod; i < mi->nr_mods; i++ ) + { + paddr_t mod_s = mi->module[i].start; + paddr_t mod_e = mod_s + mi->module[i].size; + + if ( s < mod_e && mod_s < e ) + { + mod_e = consider_modules(mod_e, e, size, align, i+1); + if ( mod_e ) + return mod_e; + + return consider_modules(s, mod_s, size, align, i+1); + } + } + + /* Now check any fdt reserved areas. */ + + nr = fdt_num_mem_rsv(device_tree_flattened); + + for ( ; i < mi->nr_mods + nr; i++ ) + { + paddr_t mod_s, mod_e; + + if ( fdt_get_mem_rsv_paddr(device_tree_flattened, + i - mi->nr_mods, + &mod_s, &mod_e ) < 0 ) + /* If we can't read it, pretend it doesn't exist... */ + continue; + + /* fdt_get_mem_rsv_paddr returns length */ + mod_e += mod_s; + + if ( s < mod_e && mod_s < e ) + { + mod_e = consider_modules(mod_e, e, size, align, i+1); + if ( mod_e ) + return mod_e; + + return consider_modules(s, mod_s, size, align, i+1); + } + } + + /* + * i is the current bootmodule we are evaluating, across all + * possible kinds of bootmodules. + * + * When retrieving the corresponding reserved-memory addresses, we + * need to index the bootinfo.reserved_mem bank starting from 0, and + * only counting the reserved-memory modules. Hence, we need to use + * i - nr. + */ + nr += mi->nr_mods; + for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s = bootinfo.reserved_mem.bank[i - nr].start; + paddr_t r_e = r_s + bootinfo.reserved_mem.bank[i - nr].size; + + if ( s < r_e && r_s < e ) + { + r_e = consider_modules(r_e, e, size, align, i + 1); + if ( r_e ) + return r_e; + + return consider_modules(s, r_s, size, align, i + 1); + } + } + return e; +} + /* * Return the end of the non-module region starting at s. In other * words return s the start of the next modules after s. From patchwork Mon Jan 29 17:18:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536099 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 34204C47DDB for ; Mon, 29 Jan 2024 17:19:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673075.1047342 (Exim 4.92) (envelope-from ) id 1rUVIE-0000aY-Oz; Mon, 29 Jan 2024 17:19:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673075.1047342; Mon, 29 Jan 2024 17:19:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVIE-0000WX-41; Mon, 29 Jan 2024 17:19:34 +0000 Received: by outflank-mailman (input) for mailman id 673075; Mon, 29 Jan 2024 17:19:32 +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 1rUVIB-0005vY-O9 for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:31 +0000 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [2a00:1450:4864:20::52f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 900c0e81-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:30 +0100 (CET) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-55a5e7fa471so2925527a12.1 for ; Mon, 29 Jan 2024 09:19:30 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:29 -0800 (PST) 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: 900c0e81-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548770; x=1707153570; 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=0I5n9NCJphRrFbEL84vyCPUVcS0YQhAxUDqpEr89QQ8=; b=v51o/lv52+2ctSV5+aCTYifHDAsB7S/QxwUfHkH6EVZfAG+oTNAhKB4xPX0pwJHxJB wqaywQk8Nosb1xBG8M76CcErI0LQV0qzKRYUAYGsd3q2TtZxGC+mMal29rb9pF+jQIAG I6Hkin7pk2XF0sV0DOnZWGRGXtULv1Z9uYd9C/z1DI2MJAlr6aqiYc77Abpm+hRYdaV6 GZVglGgEEepz37Z7kVpeogs42eerai9X7XEynPpz5Fw9if82oC5JtsGyilLmwWCJ0yuP KgrDrF+0SCtnPjzAdGy745bIkRDCzIWDZXr6Y1/ngV2aQMZ/AOyxv/T3ppwy7OXKw4+j RlpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548770; x=1707153570; 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=0I5n9NCJphRrFbEL84vyCPUVcS0YQhAxUDqpEr89QQ8=; b=u63owWfXTh14Yk9j36OAjdAqKnVds1TGUgX/9lGpJC+IBiu0VWZRyYd/6mp8KEF0ZU QI5yY/kvZGOUJLvfibir8VJrSDRiNwJVhdsQzku8EGeG5q7wjzgEueHAvOmZheQt9DmM w9Kh0XaT7IC/dDsJ6DrunmbHfkg/ic7Q00yan4rc8QS5IoTRoLYV0vgiAZZn559Lgmex LqAvHNO0pG710/Y24HMeIfpUKjjnfHcUHgsxUHFv9vZzS9GXSRZuE25dX9j50E4fEpRi NvNXgK/+uIB21jIebMJYvvvJif3UG9FItPe1CHgZymoEzH8ZEQeXMi1P9Dua2iKO9n7V /pHw== X-Gm-Message-State: AOJu0YxylS5PbW2DI/27KgHouduSqMs9O7Ms+32vBj936hVUacfnGHcs ZlNpG68jqWqSqJXahgbFbxHJrrYuBGp1snJJuxeRGqIeVg4Zqn7++MeJVuRcQNhuuRHe5roKWI5 SFyU= X-Google-Smtp-Source: AGHT+IHlr451d+Zr7M9dKVnd80bpeZnjzImUXU9tmZOircuhovcZ785ez6CzE5coA4U5vM07nTHhmA== X-Received: by 2002:a05:6402:2692:b0:55c:7aa7:53a9 with SMTP id w18-20020a056402269200b0055c7aa753a9mr5133927edd.5.1706548769838; Mon, 29 Jan 2024 09:19:29 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , Marco Solieri Subject: [PATCH v6 14/15] xen/arm: add cache coloring support for Xen Date: Mon, 29 Jan 2024 18:18:10 +0100 Message-Id: <20240129171811.21382-15-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Add the cache coloring support for Xen physical space. Since Xen must be relocated to a new physical space, some relocation functionalities must be brought back: - the virtual address of the new space is taken from 0c18fb76323b ("xen/arm: Remove unused BOOT_RELOC_VIRT_START"). - relocate_xen() and get_xen_paddr() are taken from f60658c6ae47 ("xen/arm: Stop relocating Xen"). setup_pagetables() must be adapted for coloring and for relocation. Runtime page tables are used to map the colored space, but they are also linked in boot tables so that the new space is temporarily available for relocation. This implies that Xen protection must happen after the copy. Finally, since the alternative framework needs to remap the Xen text and inittext sections, this operation must be done in a coloring-aware way. The function xen_remap_colored() is introduced for that. Signed-off-by: Carlo Nonato Signed-off-by: Marco Solieri --- v6: - squashed with BOOT_RELOC_VIRT_START patch - consider_modules() moved in another patch - removed psci and smpboot code because of new idmap work already handles that - moved xen_remap_colored() in alternative.c since it's only used there - removed xen_colored_temp[] in favor of xen_xenmap[] usage for mapping - use of boot_module_find_by_kind() to remove the need of extra parameter in setup_pagetables() - moved get_xen_paddr() in arm/llc-coloring.c since it's only used there v5: - FIXME: consider_modules copy pasted since it got moved v4: - removed set_value_for_secondary() because it was wrongly cleaning cache - relocate_xen() now calls switch_ttbr_id() --- xen/arch/arm/alternative.c | 30 ++++++++- xen/arch/arm/arm64/mmu/head.S | 57 +++++++++++++++- xen/arch/arm/arm64/mmu/mm.c | 28 ++++++-- xen/arch/arm/include/asm/mmu/layout.h | 3 + xen/arch/arm/llc-coloring.c | 61 ++++++++++++++++- xen/arch/arm/mmu/setup.c | 97 ++++++++++++++++++++++++--- xen/arch/arm/setup.c | 5 +- xen/common/llc-coloring.c | 23 +++++++ xen/include/xen/llc-coloring.h | 14 ++++ 9 files changed, 299 insertions(+), 19 deletions(-) diff --git a/xen/arch/arm/alternative.c b/xen/arch/arm/alternative.c index 016e66978b..a6b0794d80 100644 --- a/xen/arch/arm/alternative.c +++ b/xen/arch/arm/alternative.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -191,6 +192,27 @@ static int __apply_alternatives_multi_stop(void *xenmap) return 0; } +static void __init *xen_remap_colored(mfn_t xen_mfn, paddr_t xen_size) +{ + unsigned int i; + void *xenmap; + mfn_t *xen_colored_mfns; + + xen_colored_mfns = xmalloc_array(mfn_t, xen_size >> PAGE_SHIFT); + if ( !xen_colored_mfns ) + panic("Can't allocate LLC colored MFNs\n"); + + for_each_xen_colored_mfn( xen_mfn, i ) + { + xen_colored_mfns[i] = xen_mfn; + } + + xenmap = vmap(xen_colored_mfns, xen_size >> PAGE_SHIFT); + xfree(xen_colored_mfns); + + return xenmap; +} + /* * This function should only be called during boot and before CPU0 jump * into the idle_loop. @@ -209,8 +231,12 @@ void __init apply_alternatives_all(void) * The text and inittext section are read-only. So re-map Xen to * be able to patch the code. */ - xenmap = __vmap(&xen_mfn, 1U << xen_order, 1, 1, PAGE_HYPERVISOR, - VMAP_DEFAULT); + if ( llc_coloring_enabled ) + xenmap = xen_remap_colored(xen_mfn, xen_size); + else + xenmap = __vmap(&xen_mfn, 1U << xen_order, 1, 1, PAGE_HYPERVISOR, + VMAP_DEFAULT); + /* Re-mapping Xen is not expected to fail during boot. */ BUG_ON(!xenmap); diff --git a/xen/arch/arm/arm64/mmu/head.S b/xen/arch/arm/arm64/mmu/head.S index fa40b696dd..7926849ab1 100644 --- a/xen/arch/arm/arm64/mmu/head.S +++ b/xen/arch/arm/arm64/mmu/head.S @@ -427,6 +427,60 @@ fail: PRINT("- Boot failed -\r\n") b 1b ENDPROC(fail) +/* + * Copy Xen to new location and switch TTBR + * x0 ttbr + * x1 source address + * x2 destination address + * x3 length + * + * Source and destination must be word aligned, length is rounded up + * to a 16 byte boundary. + * + * MUST BE VERY CAREFUL when saving things to RAM over the copy + */ +ENTRY(relocate_xen) + /* + * Copy 16 bytes at a time using: + * x9: counter + * x10: data + * x11: data + * x12: source + * x13: destination + */ + mov x9, x3 + mov x12, x1 + mov x13, x2 + +1: ldp x10, x11, [x12], #16 + stp x10, x11, [x13], #16 + + subs x9, x9, #16 + bgt 1b + + /* + * Flush destination from dcache using: + * x9: counter + * x10: step + * x11: vaddr + * + * This is to ensure data is visible to the instruction cache + */ + dsb sy + + mov x9, x3 + ldr x10, =dcache_line_bytes /* x10 := step */ + ldr x10, [x10] + mov x11, x2 + +1: dc cvac, x11 + + add x11, x11, x10 + subs x9, x9, x10 + bgt 1b + + b switch_ttbr_id + /* * Switch TTBR * @@ -452,7 +506,8 @@ ENTRY(switch_ttbr_id) /* * 5) Flush I-cache - * This should not be necessary but it is kept for safety. + * This should not be necessary in the general case, but it's needed + * for cache coloring because in that case code is relocated. */ ic iallu isb diff --git a/xen/arch/arm/arm64/mmu/mm.c b/xen/arch/arm/arm64/mmu/mm.c index d2651c9486..07cf8040a2 100644 --- a/xen/arch/arm/arm64/mmu/mm.c +++ b/xen/arch/arm/arm64/mmu/mm.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include +#include #include #include @@ -125,27 +126,46 @@ void update_identity_mapping(bool enable) } extern void switch_ttbr_id(uint64_t ttbr); +extern void relocate_xen(uint64_t ttbr, void *src, void *dst, size_t len); typedef void (switch_ttbr_fn)(uint64_t ttbr); +typedef void (relocate_xen_fn)(uint64_t ttbr, void *src, void *dst, size_t len); void __init switch_ttbr(uint64_t ttbr) { - vaddr_t id_addr = virt_to_maddr(switch_ttbr_id); - switch_ttbr_fn *fn = (switch_ttbr_fn *)id_addr; + vaddr_t vaddr, id_addr; lpae_t pte; + if ( llc_coloring_enabled ) + vaddr = (vaddr_t)relocate_xen; + else + vaddr = (vaddr_t)switch_ttbr_id; + + id_addr = virt_to_maddr(vaddr); + /* Enable the identity mapping in the boot page tables */ update_identity_mapping(true); /* Enable the identity mapping in the runtime page tables */ - pte = pte_of_xenaddr((vaddr_t)switch_ttbr_id); + pte = pte_of_xenaddr(vaddr); pte.pt.table = 1; pte.pt.xn = 0; pte.pt.ro = 1; write_pte(&xen_third_id[third_table_offset(id_addr)], pte); /* Switch TTBR */ - fn(ttbr); + if ( llc_coloring_enabled ) + { + relocate_xen_fn *fn = (relocate_xen_fn *)id_addr; + + fn(ttbr, _start, (void *)BOOT_RELOC_VIRT_START, _end - _start); + } + else + { + switch_ttbr_fn *fn = (switch_ttbr_fn *)id_addr; + + fn(ttbr); + } /* * Disable the identity mapping in the runtime page tables. diff --git a/xen/arch/arm/include/asm/mmu/layout.h b/xen/arch/arm/include/asm/mmu/layout.h index a3b546465b..7228c9fb82 100644 --- a/xen/arch/arm/include/asm/mmu/layout.h +++ b/xen/arch/arm/include/asm/mmu/layout.h @@ -30,6 +30,7 @@ * 10M - 12M Fixmap: special-purpose 4K mapping slots * 12M - 16M Early boot mapping of FDT * 16M - 18M Livepatch vmap (if compiled in) + * 16M - 22M Cache-colored Xen text, data, bss (temporary, if compiled in) * * 1G - 2G VMAP: ioremap and early_ioremap * @@ -74,6 +75,8 @@ #define BOOT_FDT_VIRT_START (FIXMAP_VIRT_START + FIXMAP_VIRT_SIZE) #define BOOT_FDT_VIRT_SIZE _AT(vaddr_t, MB(4)) +#define BOOT_RELOC_VIRT_START (BOOT_FDT_VIRT_START + BOOT_FDT_VIRT_SIZE) + #ifdef CONFIG_LIVEPATCH #define LIVEPATCH_VMAP_START (BOOT_FDT_VIRT_START + BOOT_FDT_VIRT_SIZE) #define LIVEPATCH_VMAP_SIZE _AT(vaddr_t, MB(2)) diff --git a/xen/arch/arm/llc-coloring.c b/xen/arch/arm/llc-coloring.c index eee1e80e2d..bbb39214a8 100644 --- a/xen/arch/arm/llc-coloring.c +++ b/xen/arch/arm/llc-coloring.c @@ -9,6 +9,7 @@ #include #include +#include /* Return the LLC way size by probing the hardware */ unsigned int __init get_llc_way_size(void) @@ -62,7 +63,65 @@ unsigned int __init get_llc_way_size(void) return line_size * num_sets; } -void __init arch_llc_coloring_init(void) {} +/** + * get_xen_paddr - get physical address to relocate Xen to + * + * Xen is relocated to as near to the top of RAM as possible and + * aligned to a XEN_PADDR_ALIGN boundary. + */ +static paddr_t __init get_xen_paddr(uint32_t xen_size) +{ + struct meminfo *mi = &bootinfo.mem; + paddr_t min_size; + paddr_t paddr = 0; + int i; + + min_size = (xen_size + (XEN_PADDR_ALIGN-1)) & ~(XEN_PADDR_ALIGN-1); + + /* Find the highest bank with enough space. */ + for ( i = 0; i < mi->nr_banks; i++ ) + { + const struct membank *bank = &mi->bank[i]; + paddr_t s, e; + + if ( bank->size >= min_size ) + { + e = consider_modules(bank->start, bank->start + bank->size, + min_size, XEN_PADDR_ALIGN, 0); + if ( !e ) + continue; + +#ifdef CONFIG_ARM_32 + /* Xen must be under 4GB */ + if ( e > 0x100000000ULL ) + e = 0x100000000ULL; + if ( e < bank->start ) + continue; +#endif + + s = e - min_size; + + if ( s > paddr ) + paddr = s; + } + } + + if ( !paddr ) + panic("Not enough memory to relocate Xen\n"); + + printk("Placing Xen at 0x%"PRIpaddr"-0x%"PRIpaddr"\n", + paddr, paddr + min_size); + + return paddr; +} + +void __init arch_llc_coloring_init(void) +{ + struct bootmodule *xen_bootmodule = boot_module_find_by_kind(BOOTMOD_XEN); + + xen_bootmodule->size = xen_colored_map_size(); + xen_bootmodule->start = get_xen_paddr(xen_bootmodule->size); +} /* * Local variables: diff --git a/xen/arch/arm/mmu/setup.c b/xen/arch/arm/mmu/setup.c index 72725840b6..f3e4f6c304 100644 --- a/xen/arch/arm/mmu/setup.c +++ b/xen/arch/arm/mmu/setup.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -15,6 +16,11 @@ /* Override macros from asm/page.h to make them work with mfn_t */ #undef mfn_to_virt #define mfn_to_virt(mfn) __mfn_to_virt(mfn_x(mfn)) +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + +#define virt_to_reloc_virt(virt) \ + (((vaddr_t)virt) - XEN_VIRT_START + BOOT_RELOC_VIRT_START) /* Main runtime page tables */ @@ -69,6 +75,7 @@ static void __init __maybe_unused build_assertions(void) /* 2MB aligned regions */ BUILD_BUG_ON(XEN_VIRT_START & ~SECOND_MASK); BUILD_BUG_ON(FIXMAP_ADDR(0) & ~SECOND_MASK); + BUILD_BUG_ON(BOOT_RELOC_VIRT_START & ~SECOND_MASK); /* 1GB aligned regions */ #ifdef CONFIG_ARM_32 BUILD_BUG_ON(XENHEAP_VIRT_START & ~FIRST_MASK); @@ -132,7 +139,12 @@ static void __init __maybe_unused build_assertions(void) lpae_t __init pte_of_xenaddr(vaddr_t va) { - paddr_t ma = va + phys_offset; + paddr_t ma; + + if ( llc_coloring_enabled ) + ma = virt_to_maddr(virt_to_reloc_virt(va)); + else + ma = va + phys_offset; return mfn_to_xen_entry(maddr_to_mfn(ma), MT_NORMAL); } @@ -218,9 +230,44 @@ static void xen_pt_enforce_wnx(void) flush_xen_tlb_local(); } +static void __init create_llc_coloring_mappings(void) +{ + lpae_t pte; + unsigned int i; + struct bootmodule *xen_bootmodule = boot_module_find_by_kind(BOOTMOD_XEN); + mfn_t mfn = maddr_to_mfn(xen_bootmodule->start); + + for_each_xen_colored_mfn( mfn, i ) + { + pte = mfn_to_xen_entry(mfn, MT_NORMAL); + pte.pt.table = 1; /* level 3 mappings always have this bit set */ + xen_xenmap[i] = pte; + } + + for ( i = 0; i < XEN_NR_ENTRIES(2); i++ ) + { + vaddr_t va = BOOT_RELOC_VIRT_START + (i << XEN_PT_LEVEL_SHIFT(2)); + + pte = mfn_to_xen_entry(virt_to_mfn(xen_xenmap + + i * XEN_PT_LPAE_ENTRIES), + MT_NORMAL); + pte.pt.table = 1; + write_pte(&boot_second[second_table_offset(va)], pte); + } +} + /* - * Boot-time pagetable setup. + * Boot-time pagetable setup with coloring support * Changes here may need matching changes in head.S + * + * The cache coloring support consists of: + * - Create colored mapping that conforms to Xen color selection in xen_xenmap[] + * - Link the mapping in boot page tables using BOOT_RELOC_VIRT_START as vaddr + * - pte_of_xenaddr() takes care of translating addresses to the new space + * during runtime page tables creation + * - Relocate xen and update TTBR with the new address in the colored space + * (see switch_ttbr()) + * - Protect the new space */ void __init setup_pagetables(unsigned long boot_phys_offset) { @@ -230,6 +277,9 @@ void __init setup_pagetables(unsigned long boot_phys_offset) phys_offset = boot_phys_offset; + if ( llc_coloring_enabled ) + create_llc_coloring_mappings(); + arch_setup_page_tables(); #ifdef CONFIG_ARM_64 @@ -257,13 +307,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset) break; pte = pte_of_xenaddr(va); pte.pt.table = 1; /* third level mappings always have this bit set */ - if ( is_kernel_text(va) || is_kernel_inittext(va) ) - { - pte.pt.xn = 0; - pte.pt.ro = 1; - } - if ( is_kernel_rodata(va) ) - pte.pt.ro = 1; + pte.pt.xn = 0; /* Permissions will be enforced later. Allow execution */ xen_xenmap[i] = pte; } @@ -289,8 +333,43 @@ void __init setup_pagetables(unsigned long boot_phys_offset) ttbr = (uintptr_t) cpu0_pgtable + phys_offset; #endif + if ( llc_coloring_enabled ) + ttbr = virt_to_maddr(virt_to_reloc_virt(THIS_CPU_PGTABLE)); + switch_ttbr(ttbr); + /* Protect Xen */ + for ( i = 0; i < XEN_NR_ENTRIES(3); i++ ) + { + vaddr_t va = XEN_VIRT_START + (i << PAGE_SHIFT); + lpae_t *entry = xen_xenmap + i; + + if ( !is_kernel(va) ) + break; + + pte = read_atomic(entry); + + if ( is_kernel_text(va) || is_kernel_inittext(va) ) + { + pte.pt.xn = 0; + pte.pt.ro = 1; + } else if ( is_kernel_rodata(va) ) { + pte.pt.ro = 1; + pte.pt.xn = 1; + } else { + pte.pt.xn = 1; + pte.pt.ro = 0; + } + + write_pte(entry, pte); + } + + /* + * We modified live page-tables. Ensure the TBLs are invalidated + * before setting enforcing the WnX permissions. + */ + flush_xen_tlb_local(); + xen_pt_enforce_wnx(); #ifdef CONFIG_ARM_32 diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 28f4761705..64a449f78d 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -816,8 +816,6 @@ void asmlinkage __init start_xen(unsigned long boot_phys_offset, /* Initialize traps early allow us to get backtrace when an error occurred */ init_traps(); - setup_pagetables(boot_phys_offset); - smp_clear_cpu_maps(); device_tree_flattened = early_fdt_map(fdt_paddr); @@ -841,6 +839,9 @@ void asmlinkage __init start_xen(unsigned long boot_phys_offset, llc_coloring_init(); + setup_pagetables(boot_phys_offset); + device_tree_flattened = early_fdt_map(fdt_paddr); + setup_mm(); /* Parse the ACPI tables for possible boot-time configuration */ diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c index dace881b55..c0c4ce47bf 100644 --- a/xen/common/llc-coloring.c +++ b/xen/common/llc-coloring.c @@ -29,6 +29,8 @@ static unsigned int __ro_after_init xen_num_colors; #define mfn_color_mask (max_nr_colors - 1) #define mfn_to_color(mfn) (mfn_x(mfn) & mfn_color_mask) +#define mfn_set_color(mfn, color) (_mfn((mfn_x(mfn) & ~mfn_color_mask) | \ + (color))) /* * Parse the coloring configuration given in the buf string, following the @@ -316,6 +318,27 @@ unsigned int get_max_nr_llc_colors(void) return max_nr_colors; } +paddr_t __init xen_colored_map_size(void) +{ + return ROUNDUP((_end - _start) * max_nr_colors, XEN_PADDR_ALIGN); +} + +mfn_t __init xen_colored_mfn(mfn_t mfn) +{ + unsigned int i, color = mfn_to_color(mfn); + + for( i = 0; i < xen_num_colors; i++ ) + { + if ( color == xen_colors[i] ) + return mfn; + else if ( color < xen_colors[i] ) + return mfn_set_color(mfn, xen_colors[i]); + } + + /* Jump to next color space (max_nr_colors mfns) and use the first color */ + return mfn_set_color(mfn_add(mfn, max_nr_colors), xen_colors[0]); +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/llc-coloring.h b/xen/include/xen/llc-coloring.h index b96a7134ed..5cb560d75d 100644 --- a/xen/include/xen/llc-coloring.h +++ b/xen/include/xen/llc-coloring.h @@ -24,6 +24,17 @@ static inline void domain_llc_coloring_free(struct domain *d) {} static inline void domain_dump_llc_colors(const struct domain *d) {} #endif +/** + * Iterate over each Xen mfn in the colored space. + * @mfn: the current mfn. The first non colored mfn must be provided as the + * starting point. + * @i: loop index. + */ +#define for_each_xen_colored_mfn(mfn, i) \ + for ( i = 0, mfn = xen_colored_mfn(mfn); \ + i < (_end - _start) >> PAGE_SHIFT; \ + i++, mfn = xen_colored_mfn(mfn_add(mfn, 1)) ) + unsigned int get_llc_way_size(void); void arch_llc_coloring_init(void); int dom0_set_llc_colors(struct domain *d); @@ -35,6 +46,9 @@ struct page_info; unsigned int page_to_llc_color(const struct page_info *pg); unsigned int get_max_nr_llc_colors(void); +paddr_t xen_colored_map_size(void); +mfn_t xen_colored_mfn(mfn_t mfn); + #endif /* __COLORING_H__ */ /* From patchwork Mon Jan 29 17:18:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Nonato X-Patchwork-Id: 13536093 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 AD718C48294 for ; Mon, 29 Jan 2024 17:19:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673076.1047350 (Exim 4.92) (envelope-from ) id 1rUVIF-0000qU-LB; Mon, 29 Jan 2024 17:19:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673076.1047350; Mon, 29 Jan 2024 17:19:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUVIF-0000ni-1t; Mon, 29 Jan 2024 17:19:35 +0000 Received: by outflank-mailman (input) for mailman id 673076; Mon, 29 Jan 2024 17:19:32 +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 1rUVIC-0005vY-2e for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 17:19:32 +0000 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [2a00:1450:4864:20::529]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9072ee54-beca-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 18:19:31 +0100 (CET) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-55eed368b0bso2594684a12.0 for ; Mon, 29 Jan 2024 09:19:31 -0800 (PST) Received: from carlo-ubuntu.mo54.unimo.it (nonato.mo54.unimo.it. [155.185.85.8]) by smtp.gmail.com with ESMTPSA id eo15-20020a056402530f00b005598ec568dbsm3970494edb.59.2024.01.29.09.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:19:30 -0800 (PST) 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: 9072ee54-beca-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1706548770; x=1707153570; 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=U/xUYJDHb6Zn3w9TBBig7WhAk/AOSiMp9RlKr6dgP2E=; b=WBY8nigApNSmOxzD+7scbd3868YkFxnn8b7pwhrODPFiLU07cxK5R0mkNXXZfMURlM ZD4IJ6yTlCx3yBf2gjCDq9oGUfbUVkSAni1hka/qVnz9kIGHGgOtkOixeolk5TvTwBHY h7raKAAVDR2rjvDrXxKndL5y32pZWd97YirxKo+V2r9dMdT2519P6BL6jyjIcmRZLDSb CGyXv80wZfSUBvw920ZGYDLkSDu/woAUvJKxywCkQ5fwB5BnFgsg/fseS8MIU7wwmog4 qbix9sCs4VjwTkBrl3jkg6jvPJV7j9hNtUuRSDPrlCa1Jdk+8+2eZHChnw3a3wA9epIS lpQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706548770; x=1707153570; 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=U/xUYJDHb6Zn3w9TBBig7WhAk/AOSiMp9RlKr6dgP2E=; b=bOIs7Jz2UfenoToX3HFYiTacoeegj/05+eksfmChY6KKcaQ9xBzIwf2KLFAxREH23Z GVrdVHx06M/3uC/I1vvOoQO6LU5Yf+PsdGtepvmFU6L5NqB1WGrFUHGC9+7OGqpb668F TYXtg8e5eHTnM9ePCNRPI/Pp4b6dcjo6wJYgOEaXQB+VIob7QBlOJyV+A9JQCtReoB6N P9efU2LGhObA/KDG5jKsxNBCWFdnmwE1AqLEHkujXcgWdf6rj67pBExVqsaM/N3OqIAS TfnFnLCfWtqsxZlyqT851dNDby+zerEu68na53R9eJiW0osgNi0nqcTrJoMRsAIgQoHj qLjQ== X-Gm-Message-State: AOJu0YzhtG3xDpP3w8P14eZOts26G7Gpr3h9SjvIXH0hYbKuHdO+doMT s0B8yCuKwEBRUMUQdqs0rma64EPnkilY7Kezn1AviV8yE6vUGHLdRKFHFRNdttc21G3XWgI6Oqp Cp6Y= X-Google-Smtp-Source: AGHT+IFfyqAJQ8sAINSHdQQK6qqpoH3R0bcyfxPSeaYcI3S/L5NM69tIPus/nQPn5TvAizkT+NKrlg== X-Received: by 2002:a50:ec8d:0:b0:55f:1da7:62f6 with SMTP id e13-20020a50ec8d000000b0055f1da762f6mr1602730edr.13.1706548770565; Mon, 29 Jan 2024 09:19:30 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, Carlo Nonato , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v6 15/15] support: add cache coloring arm64 experimental feature Date: Mon, 29 Jan 2024 18:18:11 +0100 Message-Id: <20240129171811.21382-16-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129171811.21382-1-carlo.nonato@minervasys.tech> References: <20240129171811.21382-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Signed-off-by: Carlo Nonato Acked-by: Julien Grall --- v6: - new patch --- SUPPORT.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SUPPORT.md b/SUPPORT.md index a90d1108c9..f94569c862 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -363,6 +363,13 @@ by maintaining multiple physical to machine (p2m) memory mappings. Status, x86 HVM: Tech Preview Status, ARM: Tech Preview +### Cache coloring + +Allows to reserve Last Level Cache (LLC) partitions for Dom0, DomUs and Xen +itself. + + Status, Arm64: Experimental + ## Resource Management ### CPU Pools