All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Nadav Amit <namit@vmware.com>
Cc: kvm@vger.kernel.org, Krish Sadhukhan <krish.sadhukhan@oracle.com>
Subject: Re: [PATCH kvm-unit-tests] x86: vmx: Expect multiple error codes on HOST_EFER corruption
Date: Wed, 18 Mar 2020 12:29:54 +0100	[thread overview]
Message-ID: <620bcfed-a0a1-73a6-d24f-421dce4591c9@redhat.com> (raw)
In-Reply-To: <20200212195736.39540-1-namit@vmware.com>

On 12/02/20 20:57, Nadav Amit wrote:
> Extended HOST_EFER tests can fail with a different error code than the
> expected one, since the host address size bit is checked against
> EFER.LMA. This causes kvm-unit-tests to fail on bare metal. According
> to the SDM the errors are not ordered.
> 
> Expect either "invalid control" or "invalid host state" error-codes to
> allow the tests to pass. The fix somewhat relaxes the tests, as there
> are cases when only "invalid host state" is a valid instruction error,
> but doing the fix in this manner prevents intrusive changes.
> 
> Fixes: a22d7b5534c2 ("x86: vmx_tests: extend HOST_EFER tests")
> Signed-off-by: Nadav Amit <namit@vmware.com>
> ---
>  x86/vmx_tests.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 69429e5..e69c361 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -3407,6 +3407,27 @@ static void test_vmx_vmlaunch(u32 xerror)
>  	}
>  }
>  
> +/*
> + * Try to launch the current VMCS, and expect one of two possible
> + * errors (or success) codes.
> + */
> +static void test_vmx_vmlaunch2(u32 xerror1, u32 xerror2)
> +{
> +	bool success = vmlaunch_succeeds();
> +	u32 vmx_inst_err;
> +
> +	if (!xerror1 == !xerror2)
> +		report(success == !xerror1, "vmlaunch %s",
> +		       !xerror1 ? "succeeds" : "fails");
> +
> +	if (!success && (xerror1 || xerror2)) {
> +		vmx_inst_err = vmcs_read(VMX_INST_ERROR);
> +		report(vmx_inst_err == xerror1 || vmx_inst_err == xerror2,
> +		       "VMX inst error is %d or %d (actual %d)", xerror1,
> +		       xerror2, vmx_inst_err);
> +	}
> +}
> +
>  static void test_vmx_invalid_controls(void)
>  {
>  	test_vmx_vmlaunch(VMXERR_ENTRY_INVALID_CONTROL_FIELD);
> @@ -6764,7 +6785,8 @@ static void test_efer_vmlaunch(u32 fld, bool ok)
>  		if (ok)
>  			test_vmx_vmlaunch(0);
>  		else
> -			test_vmx_vmlaunch(VMXERR_ENTRY_INVALID_HOST_STATE_FIELD);
> +			test_vmx_vmlaunch2(VMXERR_ENTRY_INVALID_CONTROL_FIELD,
> +					VMXERR_ENTRY_INVALID_HOST_STATE_FIELD);
>  	} else {
>  		if (ok) {
>  			enter_guest();
> 

Queued, thanks.

Paolo


      reply	other threads:[~2020-03-18 11:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 19:57 [PATCH kvm-unit-tests] x86: vmx: Expect multiple error codes on HOST_EFER corruption Nadav Amit
2020-03-18 11:29 ` Paolo Bonzini [this message]

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=620bcfed-a0a1-73a6-d24f-421dce4591c9@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=krish.sadhukhan@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=namit@vmware.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.