{
static const char __initconst strings[MTRR_NUM_TYPES][16] =
{
- [0 ... MTRR_NUM_TYPES - 1] = "?",
[MTRR_TYPE_UNCACHABLE] = "uncachable",
[MTRR_TYPE_WRCOMB] = "write-combining",
[MTRR_TYPE_WRTHROUGH] = "write-through",
[MTRR_TYPE_WRBACK] = "write-back",
};
- return x < MTRR_NUM_TYPES ? strings[x] : "?";
+ return x < MTRR_NUM_TYPES ? (strings[x] ?: "?") : "?";
}
static unsigned int __initdata last_fixed_start;
free_cpumask_var(ept->invalidate);
}
+static const char *memory_type_to_str(unsigned int x)
+{
+ static const char memory_types[8][2] = {
+ [MTRR_TYPE_UNCACHABLE] = "UC",
+ [MTRR_TYPE_WRCOMB] = "WC",
+ [MTRR_TYPE_WRTHROUGH] = "WT",
+ [MTRR_TYPE_WRPROT] = "WP",
+ [MTRR_TYPE_WRBACK] = "WB",
+ [MTRR_NUM_TYPES] = "??"
+ };
+
+ return x < ARRAY_SIZE(memory_types) ? (memory_types[x] ?: "?") : "?";
+}
+
static void ept_dump_p2m_table(unsigned char key)
{
struct domain *d;
unsigned long record_counter = 0;
struct p2m_domain *p2m;
struct ept_data *ept;
- static const char memory_types[8][2] = {
- [0 ... 7] = "?",
- [MTRR_TYPE_UNCACHABLE] = "UC",
- [MTRR_TYPE_WRCOMB] = "WC",
- [MTRR_TYPE_WRTHROUGH] = "WT",
- [MTRR_TYPE_WRPROT] = "WP",
- [MTRR_TYPE_WRBACK] = "WB",
- [MTRR_NUM_TYPES] = "??"
- };
for_each_domain(d)
{
ept_entry->r ? 'r' : ' ',
ept_entry->w ? 'w' : ' ',
ept_entry->x ? 'x' : ' ',
- memory_types[ept_entry->emt][0],
- memory_types[ept_entry->emt][1]
+ memory_type_to_str(ept_entry->emt)[0],
+ memory_type_to_str(ept_entry->emt)[1]
?: ept_entry->emt + '0',
c ?: ept_entry->ipat ? '!' : ' ');