All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, jmattson@google.com,
	marcorr@google.com, kvm@vger.kernel.org,
	Peter Shier <pshier@google.com>
Subject: Re: [PATCH 3/3] tests: kvm: Add tests for KVM_SET_NESTED_STATE
Date: Fri, 3 May 2019 09:44:22 -0700	[thread overview]
Message-ID: <20190503164422.GC32628@linux.intel.com> (raw)
In-Reply-To: <20190502183141.258667-1-aaronlewis@google.com>

On Thu, May 02, 2019 at 11:31:41AM -0700, Aaron Lewis wrote:
> Add tests for KVM_SET_NESTED_STATE and for various code paths in its implementation in vmx_set_nested_state().
> 
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> Reviewed-by: Marc Orr <marcorr@google.com>
> Reviewed-by: Peter Shier <pshier@google.com>
> ---

...

> +int main(int argc, char *argv[])
> +{
> +	struct kvm_vm *vm;
> +	struct kvm_nested_state state;
> +	struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
> +
> +	/*
> +	 * AMD currently does not implement set_nested_state, so for now we
> +	 * just early out.
> +	 */
> +	if (!(entry->ecx & CPUID_VMX)) {
> +		fprintf(stderr, "nested VMX not enabled, skipping test\n");
> +		exit(KSFT_SKIP);
> +	}

Hmm, probably better to check KVM_CAP_NESTED_STATE.  If/when support for
AMD is added it'd be good to automatically pick up whatever testing we can.
As a bonus it'll test the cap code.

> +
> +	vm = vm_create_default(VCPU_ID, 0, 0);
> +
> +	/* Passing a NULL kvm_nested_state causes a EFAULT. */
> +	test_nested_state_expect_efault(vm, NULL);
> +
> +	/* 'size' cannot be smaller than sizeof(kvm_nested_state). */
> +	set_default_state(&state);
> +	state.size = 0;
> +	test_nested_state_expect_einval(vm, &state);
> +
> +	/*
> +	 * Setting the flags 0xf fails the flags check.  The only flags that
> +	 * can be used are:
> +	 *     KVM_STATE_NESTED_GUEST_MODE
> +	 *     KVM_STATE_NESTED_RUN_PENDING
> +	 *     KVM_STATE_NESTED_EVMCS
> +	 */
> +	set_default_state(&state);
> +	state.flags = 0xf;
> +	test_nested_state_expect_einval(vm, &state);
> +
> +	/*
> +	 * If KVM_STATE_NESTED_RUN_PENDING is set then
> +	 * KVM_STATE_NESTED_GUEST_MODE has to be set as well.
> +	 */
> +	set_default_state(&state);
> +	state.flags = KVM_STATE_NESTED_RUN_PENDING;
> +	test_nested_state_expect_einval(vm, &state);
> +
> +	/*
> +	 * TODO: When SVM support is added for KVM_SET_NESTED_STATE
> +	 *       add tests here to support it like VMX.
> +	 */
> +	if (entry->ecx & CPUID_VMX)
> +		test_vmx_nested_state(vm);
> +
> +	kvm_vm_free(vm);
> +	return 0;
> +}
> -- 
> 2.21.0.593.g511ec345e18-goog
> 

  reply	other threads:[~2019-05-03 16:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-02 18:31 [PATCH 3/3] tests: kvm: Add tests for KVM_SET_NESTED_STATE Aaron Lewis
2019-05-03 16:44 ` Sean Christopherson [this message]
2019-05-08 12:07   ` Paolo Bonzini
2019-05-08 12:05 ` Paolo Bonzini
2019-05-20 13:07   ` Thomas Huth
2019-05-20 13:28     ` Paolo Bonzini
2019-05-23  9:13       ` 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=20190503164422.GC32628@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=aaronlewis@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=pbonzini@redhat.com \
    --cc=pshier@google.com \
    --cc=rkrcmar@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.