static uint64_t dom0_colors_num;
/* Coloring configuration of Dom0 as bitmask */
static uint64_t dom0_colors_mask;
+/* Maximum number of available color(s) */
+static uint64_t col_num_max;
+/* Maximum available coloring configuration as bitmask */
+static uint64_t col_val_max;
static uint64_t way_size;
+static uint64_t addr_col_mask;
#define CTR_LINESIZE_MASK 0x7
#define CTR_SIZE_SHIFT 13
return (cache_line_size * cache_set_num);
}
+/*
+ * Return the coloring mask based on the value of @param llc_way_size.
+ * This mask represents the bits in the address that can be used
+ * for defining available colors.
+ *
+ * @param llc_way_size Last level cache way size.
+ * @return unsigned long The coloring bitmask.
+ */
+static __init unsigned long calculate_addr_col_mask(unsigned int llc_way_size)
+{
+ unsigned long addr_col_mask = 0;
+ unsigned int i;
+ unsigned int low_idx, high_idx;
+
+ low_idx = PAGE_SHIFT;
+ high_idx = get_count_order(llc_way_size) - 1;
+
+ for ( i = low_idx; i <= high_idx; i++ )
+ addr_col_mask |= (1 << i);
+
+ return addr_col_mask;
+}
+
+bool __init coloring_init(void)
+{
+ int i;
+
+ C_DEBUG("Initialize XEN coloring: \n");
+ /*
+ * If the way size is not provided by the configuration, try to get
+ * this information from hardware.
+ */
+ if ( !way_size )
+ {
+ way_size = get_llc_way_size();
+
+ if ( !way_size )
+ {
+ C_DEBUG("ERROR: way size is null\n");
+ return false;
+ }
+ }
+
+ addr_col_mask = calculate_addr_col_mask(way_size);
+ if ( !addr_col_mask )
+ {
+ C_DEBUG("ERROR: addr_col_mask is null\n");
+ return false;
+ }
+
+ col_num_max = ((addr_col_mask >> PAGE_SHIFT) + 1);
+ for ( i = 0; i < col_num_max; i++ )
+ col_val_max |= (1 << i);
+
+ C_DEBUG("Way size: 0x%lx\n", way_size);
+ C_DEBUG("Color bits in address: 0x%lx\n", addr_col_mask);
+ C_DEBUG("Max number of colors: %lu (0x%lx)\n", col_num_max, col_val_max);
+
+ return true;
+}
+
/*************************
* PARSING COLORING BOOTARGS
*/
#include <asm/tee/tee.h>
#include <xsm/xsm.h>
#include <asm/acpi.h>
+#include <asm/coloring.h>
struct bootinfo __initdata bootinfo;
fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);
+ if ( !coloring_init() )
+ panic("Xen Coloring support: setup failed\n");
+
+ xen_paddr = get_xen_paddr();
+ setup_pagetables(boot_phys_offset, xen_paddr);
+
cmdline = boot_fdt_cmdline(device_tree_flattened);
printk("Command line: %s\n", cmdline);
cmdline_parse(cmdline);