Skip to content

Commit 5f87199

Browse files
jgross1ingomolnar
authored andcommitted
x86/xen: Fix a potential problem in xen_e820_resolve_conflicts()
When fixing a conflict in xen_e820_resolve_conflicts(), the loop over the E820 map entries needs to be restarted, as the E820 map will have been modified by the fix. Otherwise entries might be skipped by accident. Fixes: be35d91 ("xen: tolerate ACPI NVS memory overlapping with Xen allocated memory") Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: xen-devel@lists.xenproject.org Link: https://patch.msgid.link/20260505080653.197775-1-jgross@suse.com
1 parent 7fd2df2 commit 5f87199

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

arch/x86/xen/setup.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,17 +695,22 @@ static void __init xen_e820_resolve_conflicts(phys_addr_t start,
695695
return;
696696

697697
end = start + size;
698-
entry = xen_e820_table.entries;
698+
mapcnt = 0;
699699

700-
for (mapcnt = 0; mapcnt < xen_e820_table.nr_entries; mapcnt++) {
700+
while (mapcnt < xen_e820_table.nr_entries) {
701+
entry = xen_e820_table.entries + mapcnt;
701702
if (entry->addr >= end)
702703
return;
703704

704705
if (entry->addr + entry->size > start &&
705-
entry->type == E820_TYPE_NVS)
706+
entry->type == E820_TYPE_NVS) {
706707
xen_e820_swap_entry_with_ram(entry);
708+
/* E820 map has been changed, restart loop! */
709+
mapcnt = 0;
710+
continue;
711+
}
707712

708-
entry++;
713+
mapcnt++;
709714
}
710715
}
711716

0 commit comments

Comments
 (0)