@@ -114,6 +114,51 @@ 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".
+DomUs colors can be set either in the xl configuration file (relative
+documentation at "docs/man/xl.cfg.pod.5.in") or via Device Tree, also for
+Dom0less configurations, as in the following example:
+
+.. raw:: html
+
+ <pre>
+ xen,xen-bootargs = "console=dtuart dtuart=serial0 dom0_mem=1G dom0_max_vcpus=1 sched=null llc-way-size=64K xen-colors=0-1 dom0-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>;
+ 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>;
+ };
+ };
+ </pre>
+
+Please refer to the relative documentation in
+"docs/misc/arm/device-tree/booting.txt".
+
Note that if no color configuration is provided for domains, they fallback to
the default one, which corresponds simply to all available colors.
@@ -162,6 +162,10 @@ with the following properties:
An integer specifying the number of vcpus to allocate to the guest.
+- colors
+ A string specifying the color configuration for the guest. Refer to
+ "docs/misc/arm/cache_coloring.rst" for syntax.
+
- vpl011
An empty property to enable/disable a virtual pl011 for the guest to
@@ -273,8 +273,11 @@ int domain_coloring_init(struct domain *d,
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);
+ xfree(config->colors.p);
+ }
}
if ( !d->arch.colors )
@@ -305,6 +308,20 @@ void domain_dump_coloring_info(struct domain *d)
print_colors(d->arch.colors, d->arch.num_colors);
}
+void prepare_color_domain_config(struct xen_arch_domainconfig *config,
+ const char *colors_str)
+{
+ unsigned int num_colors;
+
+ config->colors.p = xzalloc_array(unsigned int, max_colors);
+ if ( !config->colors.p )
+ panic("Unable to allocate cache colors\n");
+
+ if ( parse_color_config(colors_str, config->colors.p, &num_colors) )
+ panic("Error parsing the color configuration\n");
+ config->num_colors = (uint16_t)num_colors;
+}
+
/*
* Local variables:
* mode: C
@@ -25,6 +25,7 @@
#include <asm/platform.h>
#include <asm/psci.h>
#include <asm/setup.h>
+#include <asm/coloring.h>
#include <asm/cpufeature.h>
#include <asm/domain_build.h>
#include <xen/event.h>
@@ -3826,6 +3827,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 *colors_str;
BUG_ON(chosen == NULL);
dt_for_each_child_node(chosen, node)
@@ -3914,6 +3916,17 @@ void __init create_domUs(void)
d_cfg.cpupool_id = pool_id;
}
+ if ( !dt_property_read_string(node, "colors", &colors_str) )
+ {
+ if ( !IS_ENABLED(CONFIG_CACHE_COLORING) )
+ printk(XENLOG_WARNING
+ "Property 'colors' found, but coloring is disabled\n");
+ else if ( dt_find_property(node, "xen,static-mem", NULL) )
+ panic("static-mem isn't allowed when coloring is enabled\n");
+ else
+ prepare_color_domain_config(&d_cfg.arch, colors_str);
+ }
+
/*
* The variable max_init_domid is initialized with zero, so here it's
* very important to use the pre-increment operator to call
@@ -38,6 +38,9 @@ int domain_coloring_init(struct domain *d,
void domain_coloring_free(struct domain *d);
void domain_dump_coloring_info(struct domain *d);
+void prepare_color_domain_config(struct xen_arch_domainconfig *config,
+ const char *colors_str);
+
#else /* !CONFIG_CACHE_COLORING */
static inline bool __init coloring_init(void) { return true; }
@@ -45,6 +48,8 @@ static inline int domain_coloring_init(
struct domain *d, const struct xen_arch_domainconfig *config) { return 0; }
static inline void domain_coloring_free(struct domain *d) {}
static inline void domain_dump_coloring_info(struct domain *d) {}
+static inline void prepare_color_domain_config(
+ struct xen_arch_domainconfig *config, const char *colors_str) {}
#endif /* CONFIG_CACHE_COLORING */
#endif /* __ASM_ARM_COLORING_H__ */