All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Cathy Avery <cavery@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests v2 PATCH] vmx: Fix EPT accessed and dirty flag test
Date: Mon, 7 Feb 2022 21:30:18 +0000	[thread overview]
Message-ID: <YgGParjmY9X3G6+z@google.com> (raw)
In-Reply-To: <20220202135509.3286-1-cavery@redhat.com>

On Wed, Feb 02, 2022, Cathy Avery wrote:
> If ept_ad is not supported by the processor or has been
> turned off via kvm module param, test_ept_eptp() will
> incorrectly leave EPTP_AD_FLAG set in variable eptp
> causing the following failures of subsequent
> test_vmx_valid_controls calls:
> 
> FAIL: Enable-EPT enabled; reserved bits [11:7] 0: vmlaunch succeeds
> FAIL: Enable-EPT enabled; reserved bits [63:N] 0: vmlaunch succeeds

Heh, the changelog never actually provides info on how it fixes things.

  Use the saved EPTP to restore the EPTP after each sub-test instead of
  manually unwinding what was done by the sub-test, which is error prone
  and hard to follow.

  Explicitly setup a dummy EPTP, as calling the test in isolation will cause
  test failures due to lack a good starting EPTP.

> Signed-off-by: Cathy Avery <cavery@redhat.com>
> ---
> 
> * Changes in v2:
> 
> - Initialize vmcs EPTP to good values for page walk len
>   and ept memory type.
> - Restore eptp to known good values from eptp_saved
> - Cleanup test_vmx_vmlaunch to generate clearer and
>   more consolidated test reports.
>   New format suggested by seanjc@google.com
> ---
>  x86/vmx_tests.c | 39 +++++++++++++++++++++++----------------
>  1 file changed, 23 insertions(+), 16 deletions(-)
> 
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 3d57ed6..1269829 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -3392,14 +3392,21 @@ static void test_vmx_vmlaunch(u32 xerror)
>  	bool success = vmlaunch_succeeds();
>  	u32 vmx_inst_err;
>  
> -	report(success == !xerror, "vmlaunch %s",
> -	       !xerror ? "succeeds" : "fails");
> -	if (!success && xerror) {
> -		vmx_inst_err = vmcs_read(VMX_INST_ERROR);
> +	if (!success)
> +	vmx_inst_err = vmcs_read(VMX_INST_ERROR);
> +
> +	if (success && !xerror)
> +		report_pass("VMLAUNCH succeeded as expected");
> +	else if (success && xerror)
> +		report_fail("VMLAUNCH succeeded unexpectedly, wanted VM-Fail with error code = %d",
> +			    xerror);
> +	else if (!success && !xerror)
> +		report_fail("VMLAUNCH hit unexpected VM-Fail with error code = %d",
> +			    vmx_inst_err);
> +	else
>  		report(vmx_inst_err == xerror,
> -		       "VMX inst error is %d (actual %d)", xerror,
> -		       vmx_inst_err);
> -	}
> +		       "VMLAUNCH hit VM-Fail as expected, wanted error code %d, got %d",
> +		       xerror, vmx_inst_err);
>  }

The changes to test_vmx_vmlaunch() need to be a separate patch.  The addition of
setup_dummy_ept() would ideally be separate as well, though I don't care terribly
about that one.

With this split in two (or three) and an updated changelog,

Reviewed-by: Sean Christopherson <seanjc@google.com>

      reply	other threads:[~2022-02-07 21:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 13:55 [kvm-unit-tests v2 PATCH] vmx: Fix EPT accessed and dirty flag test Cathy Avery
2022-02-07 21:30 ` Sean Christopherson [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=YgGParjmY9X3G6+z@google.com \
    --to=seanjc@google.com \
    --cc=cavery@redhat.com \
    --cc=kvm@vger.kernel.org \
    /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.