All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <christoffer.dall@arm.com>
To: Andrew Jones <drjones@redhat.com>
Cc: kvm@vger.kernel.org, marc.zyngier@arm.com, pbonzini@redhat.com,
	kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH 00/13] kvm: selftests: add aarch64 framework and dirty
Date: Thu, 1 Nov 2018 10:08:25 +0100	[thread overview]
Message-ID: <20181101090825.GI12057@e113682-lin.lund.arm.com> (raw)
In-Reply-To: <20181030173820.3v2czxqkeaicfqtn@kamzik.brq.redhat.com>

On Tue, Oct 30, 2018 at 06:38:20PM +0100, Andrew Jones wrote:
> 
> Hi Christoffer,
> 
> Thanks for your interest in these tests. There isn't any documentation
> that I know of, but it's a good idea to have some. I'll write something
> up soon. I'll also try to answer your questions now.
> 

That sounds great, thanks!

> On Mon, Oct 29, 2018 at 06:40:02PM +0100, Christoffer Dall wrote:
> > Hi Drew,
> > 
> > On Tue, Sep 18, 2018 at 07:54:23PM +0200, Andrew Jones wrote:
> > > This series provides KVM selftests that test dirty log tracking on
> > > AArch64 for both 4K and 64K guest page sizes. Additionally the
> > > framework provides an easy way to test dirty log tracking with the
> > > recently posted dynamic IPA and 52bit IPA series[1].
> > 
> > I was trying to parse the commit text of patch 2, and I realized that I
> > don't understand the 'hypercall to userspace' thing at all, which
> > probably means I have no idea how the selftests work overall.
> 
> There are three parts to a kvm selftest: 1) the test code which runs in
> host userspace and _is_ the kvm userspace used with kvm, 2) the vcpu
> thread code which executes KVM_RUN for the guest code and possibly also
> some host userspace test code, and 3) the guest code, which is naturally
> run in the vcpu thread, but in guest mode.
> 
> The need for a "ucall" arises for 2's "possibly also some host userspace
> test code". In that case the guest code needs to invoke an exit from guest
> mode, not just to kvm, but all the way to kvm userspace. For AArch64, as
> you know, this can be done with an MMIO access. The reason patch 2
> generalizes the concept is because for x86 this can and is done with a
> PIO access.
> 

So in the world of normal KVM userspace, (2) would be a thread in the
same process as (1), sharing its mm.  Is this a different setup somehow,
why?

> > 
> > I then spent a while reading various bits of documentation in the kernel
> > tree, LWN, etc., only to realize that I don't understand how this test
> > framework actually works.
> > 
> > Are the selftests modules, userspace programs, or code that is compiled
> > with the kernel, and (somehow?) run from userspace.  I thought the
> > latter, partially based on your explanation at ELC, but then I don't
> > understand how the "compile and run" make target works.
> 
> The tests are standalone userspace programs which are compiled separately,
> but have dependencies on kernel headers. As stated above, for kvm, each
> selftest is a kvm userspace (including its vcpu thread code) and guest
> code combined. While there's a lot of complexity in the framework,
> particularly for memory management, and a bit for vcpu setup, most of that
> can be shared among tests using the kvm_util.h and test_util.h APIs,
> allowing a given test to only have a relatively simple main(), vcpu thread
> "vcpu_worker()" function, and "guest_code()" function. Guest mode code can
> easily share code with the kvm userspace test code (assuming the guest
> page tables are set up in the default way) and even data can be shared as
> long the accesses are done with the appropriate mappings (gva vs. hva).
> There's a small API to help with that as well.
> 

Sounds cool.  Beware of the attributes of the mappings such that both
the guest and host have mapped the memory cacheable etc., but I'm sure
you've thought of that already.

> > 
> > Can you help me paint the overall picture, or point me to the piece of
> > documentation/presentation that explains the high-level picture, which I
> > must have obviously missed somehow?
> 
> We definitely need the documentation and, in hindsight, it looks like it
> would have been a good BoF topic last week too.

An overview of the different testing approaches would be a good KVM
Forum talk for next year, IMHO.  When should you use kvm-unit-tests, and
when should you use kselftests, some examples, etc.  Just saying ;)

> 
> I think this framework has a lot of potential for KVM API testing and
> even for quick & dirty guest code instruction sequence tests (although
> instruction sequences would also fit kvm-unit-tests). I hope I can help
> get you and anyone else interested started.
> 

I'll have a look at this series and glance at the code some more, it
would be interesting to consider if using some of this for nested virt
tests makes sense.


Thanks,

    Christoffer

  parent reply	other threads:[~2018-11-01  9:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18 17:54 [PATCH 00/13] kvm: selftests: add aarch64 framework and dirty Andrew Jones
2018-09-18 17:54 ` [PATCH 01/13] kvm: selftests: vcpu_setup: set cr4.osfxsr Andrew Jones
2018-09-18 17:54 ` [PATCH 02/13] kvm: selftests: introduce ucall Andrew Jones
2018-09-18 17:54 ` [PATCH 03/13] kvm: selftests: move arch-specific files to arch-specific locations Andrew Jones
2018-09-18 17:54 ` [PATCH 04/13] kvm: selftests: add cscope make target Andrew Jones
2018-09-18 17:54 ` [PATCH 05/13] kvm: selftests: tidy up kvm_util Andrew Jones
2018-09-18 17:54 ` [PATCH 06/13] kvm: selftests: add vm_phy_pages_alloc Andrew Jones
2018-09-18 17:54 ` [PATCH 07/13] kvm: selftests: add virt mem support for aarch64 Andrew Jones
2018-09-18 17:54 ` [PATCH 08/13] kvm: selftests: add vcpu " Andrew Jones
2018-09-18 17:54 ` [PATCH 09/13] kvm: selftests: port dirty_log_test to aarch64 Andrew Jones
2018-09-18 17:54 ` [PATCH 10/13] kvm: selftests: introduce new VM mode for 64K pages Andrew Jones
2018-09-18 17:54 ` [PATCH 11/13] kvm: selftests: dirty_log_test: also test 64K pages on aarch64 Andrew Jones
2018-09-18 17:54 ` [PATCH 12/13] kvm: selftests: stop lying to aarch64 tests about PA-bits Andrew Jones
2018-09-18 17:54 ` [PATCH 13/13] kvm: selftests: support high GPAs in dirty_log_test Andrew Jones
2018-09-19 12:37 ` [PATCH 00/13] kvm: selftests: add aarch64 framework and dirty Andrew Jones
2018-09-19 13:13   ` Suzuki K Poulose
2018-10-29 17:40 ` Christoffer Dall
2018-10-30 17:38   ` Andrew Jones
2018-10-30 17:50     ` Paolo Bonzini
2018-11-01  9:08     ` Christoffer Dall [this message]
2018-11-01  9:31       ` Andrew Jones

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=20181101090825.GI12057@e113682-lin.lund.arm.com \
    --to=christoffer.dall@arm.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.