From: Julien Grall <julien@xen.org>
To: Wei Chen <Wei.Chen@arm.com>,
Carlo Nonato <carlo.nonato@minervasys.tech>,
xen-devel@lists.xenproject.org
Cc: andrew.cooper3@citrix.com, george.dunlap@citrix.com,
jbeulich@suse.com, stefano.stabellini@amd.com, wl@xen.org,
marco.solieri@unimore.it, andrea.bastoni@minervasys.tech,
lucmiccio@gmail.com,
Marco Solieri <marco.solieri@minervasys.tech>
Subject: Re: [PATCH 02/12] xen/arm: add cache coloring initialization for domains
Date: Fri, 21 Oct 2022 18:25:57 +0100 [thread overview]
Message-ID: <b800a6a8-97da-bfb3-81bb-230592ce19e1@xen.org> (raw)
In-Reply-To: <fe58de74-8bf5-50df-eb32-2d479758bfd8@arm.com>
On 26/09/2022 07:39, Wei Chen wrote:
>
>
> On 2022/8/26 20:51, Carlo Nonato wrote:
>> This commit adds array pointers to domains as well as to the hypercall
>> and configuration structure employed in domain creation. The latter is
>> used
>> both by the toolstack and by Xen itself to pass configuration data to the
>> domain creation function, so the XEN_GUEST_HANDLE macro must be
>> adopted to be
>> able to access guest memory in the first case. This implies special
>> care for
>> the copy of the configuration data into the domain data, meaning that a
>> discrimination variable for the two possible code paths (coming from
>> Xen or
>> from the toolstack) is needed.
>>
>> The initialization and free functions for colored domains are also added.
>> The former is responsible for allocating and populating the color array
>> of the domain and it also checks for configuration issues. One of those
>> issues is enabling both coloring and directmap for the domain because
>> they
>> contradicts one another. Since that, Dom0 must not be created with the
>> directmap flag.
>> The latter instead frees allocated memory.
>>
>> Signed-off-by: Carlo Nonato <carlo.nonato@minervasys.tech>
>> Signed-off-by: Marco Solieri <marco.solieri@minervasys.tech>
>> ---
>> docs/misc/arm/cache-coloring.rst | 7 ++--
>> xen/arch/arm/coloring.c | 56 +++++++++++++++++++++++++++++
>> xen/arch/arm/domain.c | 11 ++++++
>> xen/arch/arm/domain_build.c | 13 +++++--
>> xen/arch/arm/include/asm/coloring.h | 7 ++++
>> xen/arch/arm/include/asm/domain.h | 4 +++
>> xen/include/public/arch-arm.h | 8 +++++
>> 7 files changed, 102 insertions(+), 4 deletions(-)
>>
>> diff --git a/docs/misc/arm/cache-coloring.rst
>> b/docs/misc/arm/cache-coloring.rst
>> index c7adcb0f1f..345d97cb56 100644
>> --- a/docs/misc/arm/cache-coloring.rst
>> +++ b/docs/misc/arm/cache-coloring.rst
>> @@ -13,7 +13,7 @@ In order to enable and use it, few steps are needed.
>> (refer to menuconfig help for value meaning and when it should be
>> changed).
>> CONFIG_MAX_CACHE_COLORS=<n>
>> -- Assign colors to Dom0 using the `Color selection format`_ (see
>> +- Assign colors to domains using the `Color selection format`_ (see
>> `Coloring parameters`_ for more documentation pointers).
>> Background
>> @@ -109,4 +109,7 @@ Coloring parameters
>> LLC way size (as previously discussed) and Dom0 colors can be set
>> using the
>> appropriate command line parameters. See the relevant documentation in
>> -"docs/misc/xen-command-line.pandoc".
>> \ No newline at end of file
>> +"docs/misc/xen-command-line.pandoc".
>> +
>> +Note that if no color configuration is provided for domains, they
>> fallback to
>> +the default one, which corresponds simply to all available colors.
>> \ No newline at end of file
>> diff --git a/xen/arch/arm/coloring.c b/xen/arch/arm/coloring.c
>> index c010ebc01b..2b37cda067 100644
>> --- a/xen/arch/arm/coloring.c
>> +++ b/xen/arch/arm/coloring.c
>> @@ -22,6 +22,7 @@
>> * along with this program. If not, see
>> <http://www.gnu.org/licenses/>.
>> */
>> #include <xen/errno.h>
>> +#include <xen/guest_access.h>
>> #include <xen/keyhandler.h>
>> #include <xen/param.h>
>> #include <xen/types.h>
>> @@ -211,6 +212,61 @@ bool __init coloring_init(void)
>> return true;
>> }
>> +int domain_coloring_init(struct domain *d,
>> + const struct xen_arch_domainconfig *config)
>> +{
>> + if ( is_domain_direct_mapped(d) )
>> + {
>> + printk(XENLOG_ERR
>> + "Can't enable coloring and directmap at the same time
>> for %pd\n",
>> + d);
>> + return -EINVAL;
>> + }
>> +
>> + if ( is_hardware_domain(d) )
>> + {
>> + d->arch.colors = dom0_colors;
>> + d->arch.num_colors = dom0_num_colors;
>> + }
>> + else if ( config->num_colors == 0 )
>> + {
>> + printk(XENLOG_WARNING
>> + "Color config not found for %pd. Using default\n", d);
>> + d->arch.colors = xzalloc_array(unsigned int, max_colors);
>> + d->arch.num_colors = set_default_domain_colors(d->arch.colors);
>> + }
>> + else
>> + {
>> + d->arch.colors = xzalloc_array(unsigned int,
>> config->num_colors);
>> + d->arch.num_colors = config->num_colors;
>> + if ( config->from_guest )
>> + copy_from_guest(d->arch.colors, config->colors,
>> config->num_colors);
>> + else
>> + memcpy(d->arch.colors, config->colors.p,
>> + sizeof(unsigned int) * config->num_colors);
>> + }
>> +
>> + if ( !d->arch.colors )
>> + {
>> + printk(XENLOG_ERR "Colors allocation failed for %pd\n", d);
>> + return -ENOMEM;
>> + }
>> +
>> + if ( !check_colors(d->arch.colors, d->arch.num_colors) )
>> + {
>
> If we add xfree(d->arch.colors) here for non-hw domains, is it possible
> to make this function have a complete fallback process? And I know
> currently, this is handled in domain_coloring_free.
arch_domain_destroy() (and therefore domain_coloring_free()) will always
be called by arch_domain_create(). So here you will want to use XFREE()
to avoid a double free.
However, I would just rely on the free() in domain_coloring_free().
Cheers,
--
Julien Grall
next prev parent reply other threads:[~2022-10-21 17:26 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 12:50 [PATCH 00/12] Arm cache coloring Carlo Nonato
2022-08-26 12:51 ` [PATCH 01/12] xen/arm: add cache coloring initialization Carlo Nonato
2022-09-26 6:20 ` Wei Chen
2022-09-26 7:42 ` Jan Beulich
2022-09-27 14:31 ` Carlo Nonato
2022-10-21 17:14 ` Julien Grall
2022-08-26 12:51 ` [PATCH 02/12] xen/arm: add cache coloring initialization for domains Carlo Nonato
2022-09-26 6:39 ` Wei Chen
2022-09-27 14:31 ` Carlo Nonato
2022-10-21 17:25 ` Julien Grall [this message]
2022-10-21 18:02 ` Julien Grall
2022-10-25 10:53 ` Carlo Nonato
2022-10-25 11:15 ` Julien Grall
2022-10-25 11:51 ` Andrea Bastoni
2022-11-07 13:44 ` Carlo Nonato
2022-11-07 18:24 ` Julien Grall
2023-01-26 12:05 ` Jan Beulich
2023-01-26 12:07 ` Jan Beulich
2022-10-21 18:04 ` Julien Grall
2022-08-26 12:51 ` [PATCH 03/12] xen/arm: dump cache colors in domain info debug-key Carlo Nonato
2022-08-26 12:51 ` [PATCH 04/12] tools/xl: add support for cache coloring configuration Carlo Nonato
2022-10-21 18:09 ` Julien Grall
2022-08-26 12:51 ` [PATCH 05/12] xen/arm: add support for cache coloring configuration via device-tree Carlo Nonato
2022-08-26 12:51 ` [PATCH 06/12] xen/common: add cache coloring allocator for domains Carlo Nonato
2022-09-15 13:13 ` Jan Beulich
2022-09-16 16:05 ` Carlo Nonato
2022-09-19 6:26 ` Jan Beulich
2022-09-19 22:42 ` Stefano Stabellini
2022-09-20 7:54 ` Jan Beulich
2022-10-13 9:47 ` Carlo Nonato
2022-10-13 10:44 ` Jan Beulich
2022-10-17 7:06 ` Michal Orzel
2022-10-17 8:44 ` Julien Grall
2022-10-17 9:16 ` Michal Orzel
2022-08-26 12:51 ` [PATCH 07/12] xen/common: add colored heap info debug-key Carlo Nonato
2022-08-26 14:13 ` Jan Beulich
2022-08-26 16:04 ` Carlo Nonato
2022-08-26 12:51 ` [PATCH 08/12] Revert "xen/arm: setup: Add Xen as boot module before printing all boot modules" Carlo Nonato
2022-09-10 14:01 ` Julien Grall
2022-09-12 13:54 ` Carlo Nonato
2022-10-21 16:52 ` Julien Grall
2022-08-26 12:51 ` [PATCH 09/12] Revert "xen/arm: mm: Initialize page-tables earlier" Carlo Nonato
2022-09-10 14:28 ` Julien Grall
2022-09-12 13:59 ` Carlo Nonato
2022-08-26 12:51 ` [PATCH 10/12] Revert "xen/arm: Remove unused BOOT_RELOC_VIRT_START" Carlo Nonato
2022-08-26 12:51 ` [PATCH 11/12] xen/arm: add Xen cache colors command line parameter Carlo Nonato
2022-08-26 12:51 ` [PATCH 12/12] xen/arm: add cache coloring support for Xen Carlo Nonato
2022-09-10 15:22 ` Julien Grall
2022-09-10 15:23 ` Julien Grall
2022-09-15 13:25 ` Jan Beulich
2022-09-16 16:07 ` Carlo Nonato
2022-09-19 8:38 ` Jan Beulich
2022-09-27 14:31 ` Carlo Nonato
2022-09-27 15:28 ` Jan Beulich
2022-09-10 15:12 ` [PATCH 00/12] Arm cache coloring Julien Grall
2022-09-12 13:24 ` Carlo Nonato
2022-09-15 13:29 ` Jan Beulich
2022-09-15 14:52 ` Marco Solieri
2022-09-15 18:15 ` Stefano Stabellini
2022-10-22 15:13 ` Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b800a6a8-97da-bfb3-81bb-230592ce19e1@xen.org \
--to=julien@xen.org \
--cc=Wei.Chen@arm.com \
--cc=andrea.bastoni@minervasys.tech \
--cc=andrew.cooper3@citrix.com \
--cc=carlo.nonato@minervasys.tech \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=lucmiccio@gmail.com \
--cc=marco.solieri@minervasys.tech \
--cc=marco.solieri@unimore.it \
--cc=stefano.stabellini@amd.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).