]> xenbits.xensource.com Git - unikraft/unikraft.git/commit
plat/kvm/x86: Ensure free memory regions' lengths are page aligned
authorSergiu Moga <sergiu@unikraft.io>
Wed, 5 Jun 2024 08:36:20 +0000 (11:36 +0300)
committerUnikraft Bot <monkey@unikraft.io>
Wed, 5 Jun 2024 21:49:12 +0000 (21:49 +0000)
commit37c966115fb8d9f04b41e4ad8bf92a05afe76d7a
treed78ed9276b1c5b4792a52392379704ae6f7146e9
parentb95eafd9b0738f681a62ae8a0935848d8394d559
plat/kvm/x86: Ensure free memory regions' lengths are page aligned

All free memory regions must meet the following criteria:
mrd->len == mrd->pg_count * PAGE_SIZE. The `pg_count` field is
equal to the value of `PAGE_COUNT` (i.e. `DIV_ROUND_UP` of `PAGE_SIZE`)
of `len + pg_off`, however in theory this (times `PAGE_SIZE`) should be
equal to the `PAGE_ALIGN_UP` of the latter as well.
To catch cases where this may not happen (if possible), do this
differently: `PAGE_COUNT` for `pg_count` and `PAGE_ALIGN_UP` for `len`.

The lxboot boot code did not correctly compute `len` because of this,
so fix it.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1449
plat/kvm/x86/lxboot.c