Skip to content

Commit

Permalink
sel4vm, guest_ram: add 32-bit check
Browse files Browse the repository at this point in the history
64-bit x86 VMs can have RAM in 64-bit memory, which cannot be used to
store the kernel and initrd images, as those must be in 32-bit memory.
This commit adds a check when 64-bit guests are enabled to ensure the
returned region is in 32-bit space.

Signed-off-by: Chris Guikema <[email protected]>
  • Loading branch information
chrisguikema committed Oct 25, 2023
1 parent eb42051 commit de8c0ab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libsel4vm/src/guest_ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ int vm_ram_find_largest_free_region(vm_t *vm, uintptr_t *addr, size_t *size)
/* find the largest unallocated region */
for (int i = 0; i < guest_memory->num_ram_regions; i++) {
if (!guest_memory->ram_regions[i].allocated &&
guest_memory->ram_regions[i].size > largest_size) {
guest_memory->ram_regions[i].size > largest_size
#ifdef CONFIG_X86_64_VTX_64BIT_GUESTS
&& guest_memory->ram_regions[i].start < UINT32_MAX
#endif
) {
largest = i;
largest_size = guest_memory->ram_regions[i].size;
}
Expand Down

0 comments on commit de8c0ab

Please sign in to comment.