@@ -599,10 +599,23 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
}
g_strfreev(node_path);
+ /*
+ * We drop all the memory nodes which correspond to empty NUMA nodes
+ * from the device tree, because the Linux NUMA binding document
+ * states they should not be generated. Linux will get the NUMA node
+ * IDs of the empty NUMA nodes from the distance map if they are needed.
+ * This means QEMU users may be obliged to provide command lines which
+ * configure distance maps when the empty NUMA node IDs are needed and
+ * Linux's default distance map isn't sufficient.
+ */
if (ms->numa_state != NULL && ms->numa_state->num_nodes > 0) {
mem_base = binfo->loader_start;
for (i = 0; i < ms->numa_state->num_nodes; i++) {
mem_len = ms->numa_state->nodes[i].node_mem;
+ if (!mem_len) {
+ continue;
+ }
+
rc = fdt_add_memory_node(fdt, acells, mem_base,
scells, mem_len, i);
if (rc < 0) {