On Tue, Sep 06, 2022 at 06:09:24PM +0000, Ricardo Koller wrote: > The vm_create() helpers are hardcoded to place most page types (code, > page-tables, stacks, etc) in the same memslot #0, and always backed with > anonymous 4K. There are a couple of issues with that. First, tests willing to > differ a bit, like placing page-tables in a different backing source type must > replicate much of what's already done by the vm_create() functions. Second, > the hardcoded assumption of memslot #0 holding most things is spreaded > everywhere; this makes it very hard to change. > > Fix the above issues by having selftests specify how they want memory to be > laid out: define the memory regions to use for code, pt (page-tables), and > data. Introduce a new structure, struct kvm_vm_mem_params, that defines: guest > mode, a list of memory region descriptions, and some fields specifying what > regions to use for code, pt, and data. > > There is no functional change intended. The current commit adds a default > struct kvm_vm_mem_params that lays out memory exactly as before. The next > commit will change the allocators to get the region they should be using, > e.g.,: like the page table allocators using the pt memslot. > > Cc: Sean Christopherson <seanjc@xxxxxxxxxx> > Cc: Andrew Jones <andrew.jones@xxxxxxxxx> > Signed-off-by: Ricardo Koller <ricarkol@xxxxxxxxxx> > --- > .../selftests/kvm/include/kvm_util_base.h | 51 +++++++++++++++- > .../selftests/kvm/lib/aarch64/processor.c | 3 +- > tools/testing/selftests/kvm/lib/kvm_util.c | 58 ++++++++++++++++--- > 3 files changed, 102 insertions(+), 10 deletions(-) > Reviewed-by: Andrew Jones <andrew.jones@xxxxxxxxx>