On 02.05.2024 18:55, Carlo Nonato wrote: > Add a new domctl hypercall to allow the user to set LLC coloring > configurations. Colors can be set only once, just after domain creation, > since recoloring isn't supported. > > Based on original work from: Luca Miccio <lucmic...@gmail.com> > > Signed-off-by: Carlo Nonato <carlo.non...@minervasys.tech> > Signed-off-by: Marco Solieri <marco.soli...@minervasys.tech>
Reviewed-by: Jan Beulich <jbeul...@suse.com> with one remark: > @@ -226,6 +226,46 @@ void domain_llc_coloring_free(struct domain *d) > xfree(__va(__pa(d->llc_colors))); > } > > +int domain_set_llc_colors(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 ) > + { > + domain_set_default_colors(d); > + return 0; > + } > + > + if ( config->num_llc_colors > max_nr_colors ) > + return -EINVAL; > + > + colors = xmalloc_array(unsigned int, config->num_llc_colors); > + if ( !colors ) > + return -ENOMEM; > + > + if ( copy_from_guest(colors, config->llc_colors, config->num_llc_colors) > ) > + { > + xfree(colors); > + return -EFAULT; > + } > + > + if ( !check_colors(colors, config->num_llc_colors) ) > + { > + printk(XENLOG_ERR "Bad LLC color config for %pd\n", d); Slightly shorter (and more in line with what we have elsewhere) as printk(XENLOG_ERR "%pd: bad LLC color config\n", d); Jan