From: Sean Christopherson <seanjc@google.com>
To: Ricardo Koller <ricarkol@google.com>
Cc: Andrew Jones <andrew.jones@linux.dev>,
kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
pbonzini@redhat.com, maz@kernel.org, alexandru.elisei@arm.com,
eric.auger@redhat.com, oupton@google.com, reijiw@google.com,
rananta@google.com, bgardon@google.com, dmatclack@google.com,
axelrasmussen@google.com
Subject: Re: [PATCH v5 07/13] KVM: selftests: Change ____vm_create() to take struct kvm_vm_mem_params
Date: Tue, 30 Aug 2022 22:49:11 +0000 [thread overview]
Message-ID: <Yw6T591G5hGTBx2t@google.com> (raw)
In-Reply-To: <Yw6JAiIfenYafJnZ@google.com>
On Tue, Aug 30, 2022, Ricardo Koller wrote:
> On Mon, Aug 29, 2022 at 07:25:08PM +0200, Andrew Jones wrote:
> > On Tue, Aug 23, 2022 at 11:47:21PM +0000, Ricardo Koller wrote:
> > I feel we'll be revisiting this frequently when more and more region types
> > are desired. For example, Sean wants a read-only memory region for ucall
> > exits. How about putting a mem slot array in struct kvm_vm, defining an
> > enum to index it (which will expand), and then single helper function,
> > something like
> >
> > inline struct userspace_mem_region *
> > vm_get_mem_region(struct kvm_vm *vm, enum memslot_type mst)
> > {
> > return memslot2region(vm, vm->memslots[mst]);
> > }
> >
> > > +
> > > /* Minimum allocated guest virtual and physical addresses */
> > > #define KVM_UTIL_MIN_VADDR 0x2000
> > > #define KVM_GUEST_PAGE_TABLE_MIN_PADDR 0x180000
> > > @@ -637,19 +662,51 @@ vm_paddr_t vm_phy_pages_alloc(struct kvm_vm *vm, size_t num,
> > > vm_paddr_t paddr_min, uint32_t memslot);
> > > vm_paddr_t vm_alloc_page_table(struct kvm_vm *vm);
> > >
> > > +#define MEM_PARAMS_MAX_MEMSLOTS 3
> >
> > And this becomes MEMSLOT_MAX of the enum proposed above
> >
> > enum memslot_type {
> > MEMSLOT_CODE,
> > MEMSLOT_PT,
> > MEMSLOT_DATA,
"memslot" is going to be confusing, e.g. MEMSLOT_MAX is some arbitrary selftests
constant that has no relationship to maximum number of memslots.
> > MEMSLOT_MAX,
I dislike "max" because it's ambiguous, e.g. is it the maximum number of regions,
or is the max valid region?
Maybe something like this?
enum kvm_mem_region_type {
MEM_REGION_CODE
...
NR_MEM_REGIONS,
}
> > > +#else
> > > + .mode = VM_MODE_DEFAULT,
> > > +#endif
> > > + .region[0] = {
> > > + .src_type = VM_MEM_SRC_ANONYMOUS,
> > > + .guest_paddr = 0,
> > > + .slot = 0,
> > > + /*
> > > + * 4mb when page size is 4kb. Note that vm_nr_pages_required(),
> > > + * the function used by most tests to calculate guest memory
> > > + * requirements uses around ~520 pages for more tests.
> >
> > ...requirements, currently returns ~520 pages for the majority of tests.
> >
> > > + */
> > > + .npages = 1024,
> >
> > And here we double it, but it's still fragile. I see we override this
> > in __vm_create() below though, so now I wonder why we set it at all.
> >
>
> I would prefer having a default that can be used by a test as-is. WDYT?
> or should we make it explicit that the default needs some updates?
In that case, the default should be '0'. There are two users of ____vm_create().
__vm_create() takes the number of "extra" pages and calculates the "base" number
of pages. vm_create_barebones() passes '0', i.e. can use default.
If '0' as a default is too weird, make it an illegal value and force the caller
to define the number of pages.
It's not a coincidence that those are the only two callers, ____vm_create() isn't
intended to be used directly. If a test wants to create a VM just to create a VM,
then it shoulid use vm_create_barebones(). If a test wants to doing anything
remotely useful with the VM, it should use __vm_create() or something higher up
the food chain.
next prev parent reply other threads:[~2022-08-30 22:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 23:47 [PATCH v5 00/13] KVM: selftests: Add aarch64/page_fault_test Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 01/13] KVM: selftests: Add a userfaultfd library Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 02/13] KVM: selftests: aarch64: Add virt_get_pte_hva() library function Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 03/13] KVM: selftests: Add missing close and munmap in __vm_mem_region_delete() Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 04/13] KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 05/13] tools: Copy bitfield.h from the kernel sources Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 06/13] KVM: selftests: Stash backing_src_type in struct userspace_mem_region Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 07/13] KVM: selftests: Change ____vm_create() to take struct kvm_vm_mem_params Ricardo Koller
2022-08-29 17:25 ` Andrew Jones
2022-08-30 22:02 ` Ricardo Koller
2022-08-30 22:49 ` Sean Christopherson [this message]
2022-09-01 18:28 ` Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 08/13] KVM: selftests: Use the right memslot for code, page-tables, and data allocations Ricardo Koller
2022-08-29 17:34 ` Andrew Jones
2022-08-23 23:47 ` [PATCH v5 09/13] KVM: selftests: aarch64: Add aarch64/page_fault_test Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 10/13] KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 11/13] KVM: selftests: aarch64: Add dirty logging " Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 12/13] KVM: selftests: aarch64: Add readonly memslot " Ricardo Koller
2022-08-23 23:47 ` [PATCH v5 13/13] KVM: selftests: aarch64: Add mix of " Ricardo Koller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yw6T591G5hGTBx2t@google.com \
--to=seanjc@google.com \
--cc=alexandru.elisei@arm.com \
--cc=andrew.jones@linux.dev \
--cc=axelrasmussen@google.com \
--cc=bgardon@google.com \
--cc=dmatclack@google.com \
--cc=eric.auger@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=rananta@google.com \
--cc=reijiw@google.com \
--cc=ricarkol@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox