]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen/arm: make the colors bitmask an array
authorStefano Stabellini <sstabellini@kernel.org>
Sat, 14 Dec 2019 00:01:12 +0000 (16:01 -0800)
committerLuca Miccio <206497@studenti.unimore.it>
Mon, 6 Jan 2020 14:54:27 +0000 (15:54 +0100)
We might have more than 64 colors, so turn the simple uint64_t colors
bitmask in xen_domctl_createdomain into an array. Choose uint32_t
instead of uint64_t as array unit because it matches the device tree
cell size, making it easier to populate from device tree.

From libxl, populate the array properly. From arch_domain_create in Xen
parse it properly.

In create_domUs for dom0less domUs read "colors" from device tree,
expecting a variable number of cells. Also update the documentation.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
docs/misc/arm/cache_coloring.rst
tools/libxl/libxl_arm.c
xen/arch/arm/domain.c
xen/arch/arm/domain_build.c
xen/include/public/arch-arm.h

index 082afb1b6cad114960dd841d34a48401b072221d..06a1bee951b37ae9787050e2992c867068b0cdd9 100644 (file)
@@ -133,7 +133,7 @@ Configuration example:
             #size-cells = <0x1>;
             compatible = "xen,domain";
             memory = <0x0 0x40000>;
-            colors = <0x0 0x0f00>;
+            colors = <0x0f00>;
             cpus = <0x1>;
             vpl011 = <0x1>;
 
index 7bd358102d451f134142a8191b8278cdb2c5dd6f..a0a39f3b8ea9eb2181199c333afb385ffaac995b 100644 (file)
@@ -103,10 +103,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
     }
 
     config->arch.colors.max_colors = d_config->b_info.num_colors;
-    config->arch.colors.colors = 0;
-    for (i = 0; i < d_config->b_info.num_colors; i++)
-        config->arch.colors.colors |= ((unsigned long long)1 <<
-                                     d_config->b_info.colors[i]);
+    for (i = 0; i < sizeof(config->arch.colors.colors) / 4; i++)
+        config->arch.colors.colors[i] = 0;
+    for (i = 0; i < d_config->b_info.num_colors; i++) {
+        unsigned int j = d_config->b_info.colors[i] / 32;
+        if (j > sizeof(config->arch.colors.colors) / 4)
+            return ERROR_FAIL;
+        config->arch.colors.colors[j] |= (1 << (d_config->b_info.colors[i] % 32));
+    }
     LOG(DEBUG, "Setup domain colors");
 
     return 0;
index 480eaf9a8ae6d870221afd83915100ac048d2f05..bb2369b036c6bce8bd9afab9900fc5a8d84e9211 100644 (file)
@@ -780,9 +780,11 @@ int arch_domain_create(struct domain *d,
         }
 
         d->max_colors = config->arch.colors.max_colors;
-        for ( i = 0, k = 0; k < d->max_colors && i < 64; i++ )
+        for ( i = 0, k = 0;
+              k < d->max_colors && i < sizeof(config->arch.colors.colors) * 8;
+              i++ )
         {
-            if ( config->arch.colors.colors & (1ULL << i) )
+            if ( config->arch.colors.colors[i / 32] & (1 << (i % 32)) )
                 d->colors[k++] = i;
         }
     }
index 8e4b76c01130c28817973571ece79c18a00a5d86..150ee137e26f6e13ba3843714e8545ce6c2e48e0 100644 (file)
@@ -2445,8 +2445,10 @@ void __init create_domUs(void)
 {
     struct dt_device_node *node;
     const struct dt_device_node *chosen = dt_find_node_by_path("/chosen");
-    u64 col_val = 0;
-    int rc;
+    u32 col_val;
+    const u32 *cells;
+    u32 len;
+    int cell, i, k;
 
     BUG_ON(chosen == NULL);
     dt_for_each_child_node(chosen, node)
@@ -2484,25 +2486,29 @@ void __init create_domUs(void)
         }
 
         d_cfg.arch.colors.max_colors = 0;
-        d_cfg.arch.colors.colors = 0ULL;
-        rc = dt_property_read_u64(node, "colors", &col_val);
-        if ( rc && col_val )
-        {
-            int i;
+        memset(&d_cfg.arch.colors.colors, 0x0, sizeof(d_cfg.arch.colors.colors));
 
+        cells = dt_get_property(node, "colors", &len);
+        if ( cells != NULL && len > 0 )
+        {
             if ( !get_max_colors() )
                 panic("Coloring requested but no colors configuration found!\n");
 
-            if ( col_val >= (1 << get_max_colors()) )
-                panic("Invalid DomU colors configuration 0x%"PRIx64"\n", col_val);
+            if ( len > sizeof(d_cfg.arch.colors.colors) )
+                panic("Dom0less DomU color information is invalid\n");
 
-            printk("Colored configuration: 0x%"PRIx64"\n", col_val);
-
-            /* Calculate number of bit set */
-            for ( i = 0; i < 64; i++)
-                if ( col_val & (1ULL << i) )
-                    d_cfg.arch.colors.max_colors++;
-            d_cfg.arch.colors.colors = col_val;
+            for ( k = 0, cell = len/4 - 1; cell >= 0; cell--, k++ )
+            {
+                col_val = be32_to_cpup(&cells[cell]);
+                if ( col_val )
+                {
+                    /* Calculate number of bit set */
+                    for ( i = 0; i < 32; i++)
+                        if ( col_val & (1 << i) )
+                            d_cfg.arch.colors.max_colors++;
+                    d_cfg.arch.colors.colors[k] = col_val;
+                }
+            }
         }
 
         d = domain_create(++max_init_domid, &d_cfg, false);
index 558e1e74aa2aeb2fc6f5cde6f0279ca212a0e467..e45b45f17a163542191ef6bd0afa29707bd91d1d 100644 (file)
@@ -299,9 +299,10 @@ struct vcpu_guest_context {
 typedef struct vcpu_guest_context vcpu_guest_context_t;
 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
+#define MAX_COLORS_CELLS 4
 struct color_guest_config {
     uint32_t max_colors;
-    uint64_t colors;
+    uint32_t colors[MAX_COLORS_CELLS];
 };
 
 /*