All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Arthur Chunqi Li <yzt356@gmail.com>
Cc: kvm@vger.kernel.org, jan.kiszka@web.de, pbonzini@redhat.com
Subject: Re: [PATCH] kvm-unit-tests: VMX: Fix confused definition of rflags
Date: Mon, 5 Aug 2013 11:29:07 +0300	[thread overview]
Message-ID: <20130805082907.GC2258@redhat.com> (raw)
In-Reply-To: <1375198860-21152-1-git-send-email-yzt356@gmail.com>

On Tue, Jul 30, 2013 at 11:41:00PM +0800, Arthur Chunqi Li wrote:
> Change "rflags" in "struct regs" to "host_rflags". Remove settings
> to GUEST_RFLAGS since GUEST_RFLAGS can be set by vmwrite. Treat
> host_rflags as host rflags before and after vmenter.
> 
I am not sure the change is for the better. Before the change one could
set up rflags for guest environment by setting regs.rflags, no special
init function had to be written. I do not see any problem with correct
code, except that rflags is not correct on a guest entry, but this
should be easy to fix. 

> Besides, add checks to flags after vmenter.
> 
> Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
> ---
>  x86/vmx.c |   11 ++++++-----
>  x86/vmx.h |    2 +-
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/x86/vmx.c b/x86/vmx.c
> index 7467927..082c3bb 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -481,6 +481,8 @@ static int vmx_run()
>  			"vmresume\n\t"
>  			"2: "
>  			"setbe %0\n\t"
> +			"jbe vmx_return\n\t"
> +			"ud2\n\t"
>  			"vmx_return:\n\t"
>  			SAVE_GPR_C
>  			SAVE_RFLAGS
> @@ -505,15 +507,15 @@ static int vmx_run()
>  		return 0;
>  	case VMX_TEST_LAUNCH_ERR:
>  		printf("%s : vmlaunch failed.\n", __func__);
> -		if ((!(regs.rflags & X86_EFLAGS_CF) && !(regs.rflags & X86_EFLAGS_ZF))
> -			|| ((regs.rflags & X86_EFLAGS_CF) && (regs.rflags & X86_EFLAGS_ZF)))
> +		if ((!(regs.host_rflags & X86_EFLAGS_CF) && !(regs.host_rflags & X86_EFLAGS_ZF))
> +			|| ((regs.host_rflags & X86_EFLAGS_CF) && (regs.host_rflags & X86_EFLAGS_ZF)))
>  			printf("\tvmlaunch set wrong flags\n");
>  		report("test vmlaunch", 0);
>  		break;
>  	case VMX_TEST_RESUME_ERR:
>  		printf("%s : vmresume failed.\n", __func__);
> -		if ((!(regs.rflags & X86_EFLAGS_CF) && !(regs.rflags & X86_EFLAGS_ZF))
> -			|| ((regs.rflags & X86_EFLAGS_CF) && (regs.rflags & X86_EFLAGS_ZF)))
> +		if ((!(regs.host_rflags & X86_EFLAGS_CF) && !(regs.host_rflags & X86_EFLAGS_ZF))
> +			|| ((regs.host_rflags & X86_EFLAGS_CF) && (regs.host_rflags & X86_EFLAGS_ZF)))
>  			printf("\tvmresume set wrong flags\n");
>  		report("test vmresume", 0);
>  		break;
> @@ -540,7 +542,6 @@ static int test_run(struct vmx_test *test)
>  	test->exits = 0;
>  	current = test;
>  	regs = test->guest_regs;
> -	vmcs_write(GUEST_RFLAGS, regs.rflags | 0x2);
>  	launched = 0;
>  	printf("\nTest suite : %s\n", test->name);
>  	vmx_run();
> diff --git a/x86/vmx.h b/x86/vmx.h
> index 1fb9738..d80e000 100644
> --- a/x86/vmx.h
> +++ b/x86/vmx.h
> @@ -27,7 +27,7 @@ struct regs {
>  	u64 r13;
>  	u64 r14;
>  	u64 r15;
> -	u64 rflags;
> +	u64 host_rflags;
>  };
>  
>  struct vmx_test {
> -- 
> 1.7.9.5

--
			Gleb.

  parent reply	other threads:[~2013-08-05  8:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30 15:41 [PATCH] kvm-unit-tests: VMX: Fix confused definition of rflags Arthur Chunqi Li
2013-07-30 15:43 ` Arthur Chunqi Li
2013-08-05  8:29 ` Gleb Natapov [this message]
2013-08-05  8:48   ` Arthur Chunqi Li
2013-08-05  9:10     ` Gleb Natapov
2013-08-05  9:27       ` Gmail

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=20130805082907.GC2258@redhat.com \
    --to=gleb@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yzt356@gmail.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.