kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com
Subject: Re: [kvm-unit-tests PATCH v4 2/3] x86: Add support for running a nested guest multiple times in one test
Date: Fri, 21 Jan 2022 17:41:28 +0000	[thread overview]
Message-ID: <YerwSEIvpVs9un23@google.com> (raw)
In-Reply-To: <20220121155855.213852-3-aaronlewis@google.com>

On Fri, Jan 21, 2022, Aaron Lewis wrote:
> KUT has a limit of only being able to run one nested guest per vmx test.
> This is limiting and not necessary.  Add support for allowing a test to
> run guest code multiple times.
> 
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> ---
>  x86/vmx.c | 24 ++++++++++++++++++++++--
>  x86/vmx.h |  2 ++
>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/x86/vmx.c b/x86/vmx.c
> index f4fbb94..51eed8c 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -1884,15 +1884,35 @@ void test_add_teardown(test_teardown_func func, void *data)
>  	step->data = data;
>  }
>  
> +static void __test_set_guest(test_guest_func func)
> +{
> +	assert(current->v2);
> +	v2_guest_main = func;
> +}
> +
>  /*
>   * Set the target of the first enter_guest call. Can only be called once per
>   * test. Must be called before first enter_guest call.
>   */
>  void test_set_guest(test_guest_func func)
>  {
> -	assert(current->v2);
>  	TEST_ASSERT_MSG(!v2_guest_main, "Already set guest func.");
> -	v2_guest_main = func;
> +	__test_set_guest(func);
> +}
> +
> +/*
> + * Set the target of the enter_guest call and reset the RIP so 'func' will
> + * start from the beginning.  This can be called multiple times per test.
> + */
> +void test_override_guest(test_guest_func func)
> +{
> +	__test_set_guest(func);
> +	init_vmcs_guest();
> +}
> +
> +void test_set_guest_finished(void)
> +{
> +	guest_finished = 1;

Adding test_set_guest_finished() should be a separate commit.

>  }
>  
>  static void check_for_guest_termination(union exit_reason exit_reason)
> diff --git a/x86/vmx.h b/x86/vmx.h
> index 4423986..11cb665 100644
> --- a/x86/vmx.h
> +++ b/x86/vmx.h
> @@ -1055,7 +1055,9 @@ void hypercall(u32 hypercall_no);
>  typedef void (*test_guest_func)(void);
>  typedef void (*test_teardown_func)(void *data);
>  void test_set_guest(test_guest_func func);
> +void test_override_guest(test_guest_func func);
>  void test_add_teardown(test_teardown_func func, void *data);
>  void test_skip(const char *msg);
> +void test_set_guest_finished(void);
>  
>  #endif
> -- 
> 2.35.0.rc0.227.g00780c9af4-goog
> 

  reply	other threads:[~2022-01-21 17:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21 15:58 [kvm-unit-tests PATCH v4 0/3] Add additional testing for routing L2 exceptions Aaron Lewis
2022-01-21 15:58 ` [kvm-unit-tests PATCH v4 1/3] x86: Make exception_mnemonic() visible to the tests Aaron Lewis
2022-01-21 17:38   ` Sean Christopherson
2022-01-21 15:58 ` [kvm-unit-tests PATCH v4 2/3] x86: Add support for running a nested guest multiple times in one test Aaron Lewis
2022-01-21 17:41   ` Sean Christopherson [this message]
2022-01-21 15:58 ` [kvm-unit-tests PATCH v4 3/3] x86: Add test coverage for nested_vmx_reflect_vmexit() testing Aaron Lewis
2022-01-21 18:00   ` Sean Christopherson
2022-01-21 19:12     ` Aaron Lewis
2022-01-26 17:31       ` Paolo Bonzini

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=YerwSEIvpVs9un23@google.com \
    --to=seanjc@google.com \
    --cc=aaronlewis@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).