]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen/arch: add default colors selection function
authorLuca Miccio <206497@studenti.unimore.it>
Wed, 21 Aug 2019 16:13:27 +0000 (18:13 +0200)
committerLuca Miccio <206497@studenti.unimore.it>
Mon, 6 Jan 2020 13:59:40 +0000 (14:59 +0100)
When cache coloring support is enabled, a color assignment is needed for
every domain. Introduce a function computing a default configuration
with a safe and common value -- the dom0 color selection.

Signed-off-by: Luca Miccio <206497@studenti.unimore.it>
Signed-off-by: Marco Solieri <marco.solieri@unimore.it>
xen/arch/arm/coloring.c
xen/include/asm-arm/coloring.h

index e283f0dddc161cc2d18a0b89b4b8f76c33bc472f..aedbc6983515a8fad8b1c22fccbbf22b30672502 100644 (file)
@@ -144,6 +144,21 @@ static __init unsigned long calculate_addr_col_mask(unsigned int llc_way_size)
     return addr_col_mask;
 }
 
+static int copy_mask_to_list(
+    uint64_t col_val, uint32_t *col_list, uint64_t col_num)
+{
+    unsigned int i, k;
+
+    if ( !col_list )
+        return -EINVAL;
+
+    for ( i = 0, k = 0; k < col_num; i++ )
+        if (col_val & (1 << i))
+            col_list[k++] = i;
+
+    return 0;
+}
+
 bool __init coloring_init(void)
 {
     int i;
@@ -182,6 +197,26 @@ bool __init coloring_init(void)
     return true;
 }
 
+uint32_t *setup_default_colors(unsigned int *col_num)
+{
+    uint32_t *col_list;
+
+    if ( dom0_colors_num )
+    {
+        *col_num = dom0_colors_num;
+        col_list = xzalloc_array(uint32_t, dom0_colors_num);
+        if ( !col_list )
+        {
+            C_DEBUG("setup_default_colors: Alloc failed\n");
+            return NULL;
+        }
+        copy_mask_to_list(dom0_colors_mask, col_list, dom0_colors_num);
+        return col_list;
+    }
+
+    return NULL;
+}
+
 /**
  * Compute color id from the page @param pg.
  * Page size determines the lowest available bit, while add_col_mask is used to
index 58f799b01d50073c6ff671d32440531ef8b5e1d5..1504ee2aadcf995eebafed9706b4fc617310a760 100644 (file)
@@ -46,6 +46,13 @@ unsigned long color_from_page(struct page_info *pg);
 /* Return the maximum available number of colors supported by the hardware */
 uint64_t get_max_colors(void);
 
+/*
+ * Return an array with default colors selection and store the number of
+ * colors in @param col_num. The array selection will be equal to the dom0
+ * color configuration.
+ */
+uint32_t *setup_default_colors(unsigned int *col_num);
+
 /* Colored allocator functions */
 bool init_col_heap_pages(struct page_info *pg, unsigned long nr_pages);
 struct page_info *alloc_col_domheap_page(