]> xenbits.xensource.com Git - unikraft/unikraft.git/commit
uk/plat/memory: Introduce `pg_off` and `pg_count` memregion fields
authorSergiu Moga <sergiu@unikraft.io>
Sat, 28 Oct 2023 15:57:12 +0000 (18:57 +0300)
committerRazvan Deaconescu <razvan.deaconescu@upb.ro>
Wed, 15 May 2024 12:22:43 +0000 (15:22 +0300)
commitad52a90ffccb5bb6c3681d9d16d5b48e9d2dfc79
treec7514e43d3ce8eb490863c09017c74394170b90c
parent8e9b7a2036c064d358e48da019e9133d27df4c56
uk/plat/memory: Introduce `pg_off` and `pg_count` memregion fields

To make memory region management easier w.r.t. alignment handling,
define two additional fields for `struct ukplat_memregion_desc`:
- `pg_off` to represent the in-page offset from where the actual
resource this memory region is dedicated to starts
- `pg_count` to represent the length of the entire, end-to-end
page-aligned, memory region in number of pages

Thus, the definition of some other fields shall then change:
- `pbase` will be the physical page-aligned base address of the
region. This means that in order to get the actual address of a
resource, one may have to make the following basic addition:
`pbase` + `pg_off`
- `vbase` same as `pbase` but for virtual base address
- `len` will now represent the length of the resource inside the
region, not the length of the region.

E.g.
For a resource with address `0x1050` and length `0x430` the
corresponding memory region descriptor will have the following
values:
- `pbase` and `vbase` equal to `0x1000` (`PAGE_ALIGN_DOWN(0x1050)`)
- `pg_off` equal to `0x50` (`0x1050 & ~PAGE_MASK`)
- `pg_count` equal to `5` (`PAGE_COUNT(0x1050 + 0x430)`)
- `len` equal to `0x430`

The other fields (`type`, `flags`, `name`) will keep their meaning.

Now with the new structure, make sure that every call site to
`ukplat_memregion_list_insert` also initializes `pg_off` and
`pg_count` accordingly.

Most importantly, deprecate the manual alignment and restoration
of memory regions during coalescing, as it is not longer needed.
The newly introduced fields guarantee that `pbase` and `pg_count`
combined will always yield end-to-end aligned memory regions.

In the case of printing, make memory map printing functionality
show two sets of address ranges for each memory region descriptor:
one for the page-aligned start and end of the memory region and one
for the real, potentially misaligned, start and end addresses of the
memory region descriptor (the actual start/end addresses of the resource
the region is meant to map).

s into prev

s into prev
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Michalis Pappas <mpappas@fastmail.fm>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
GitHub-Closes: #1212
17 files changed:
include/uk/arch/paging.h
include/uk/plat/memory.h
lib/vfscore/automount.c
plat/common/bootinfo.c
plat/common/bootinfo_fdt.c
plat/common/include/uk/plat/common/bootinfo.h
plat/common/include/uk/plat/common/memory.h
plat/common/memory.c
plat/common/paging.c
plat/kvm/arm/firecracker_bpt64.S
plat/kvm/arm/qemu_bpt64.S
plat/kvm/efi.c
plat/kvm/x86/lxboot.c
plat/kvm/x86/multiboot.c
plat/kvm/x86/pagetable64.S
plat/xen/x86/setup.c
support/scripts/mkbootinfo.py