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: Separate host and guest rflags
Date: Mon, 5 Aug 2013 16:18:00 +0300	[thread overview]
Message-ID: <20130805131800.GI10891@redhat.com> (raw)
In-Reply-To: <1375706605-14980-1-git-send-email-yzt356@gmail.com>

On Mon, Aug 05, 2013 at 08:43:25PM +0800, Arthur Chunqi Li wrote:
> Separate host_rflags and guest_rflags (regs.rflags used for guest).
> Fix bug of set/get guest rflags when vmenter/vmexit.
> 
> Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
> ---
>  x86/vmx.c |   11 +++++++----
>  x86/vmx.h |    4 ++--
>  2 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/x86/vmx.c b/x86/vmx.c
> index 7467927..7b28aca 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -19,6 +19,7 @@ struct regs regs;
>  struct vmx_test *current;
>  u64 hypercall_field = 0;
>  bool launched;
> +u64 host_rflags;
>  
Can't you define in on stack?

>  extern u64 gdt64_desc[];
>  extern u64 idt_descr[];
> @@ -440,12 +441,14 @@ static int exit_handler()
>  	int ret;
>  
>  	current->exits++;
> +	regs.rflags = vmcs_read(GUEST_RFLAGS);
>  	current->guest_regs = regs;
>  	if (is_hypercall())
>  		ret = handle_hypercall();
>  	else
>  		ret = current->exit_handler();
>  	regs = current->guest_regs;
> +	vmcs_write(GUEST_RFLAGS, regs.rflags);
>  	switch (ret) {
>  	case VMX_TEST_VMEXIT:
>  	case VMX_TEST_RESUME:
> @@ -505,15 +508,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 ((!(host_rflags & X86_EFLAGS_CF) && !(host_rflags & X86_EFLAGS_ZF))
> +			|| ((host_rflags & X86_EFLAGS_CF) && (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 ((!(host_rflags & X86_EFLAGS_CF) && !(host_rflags & X86_EFLAGS_ZF))
> +			|| ((host_rflags & X86_EFLAGS_CF) && (host_rflags & X86_EFLAGS_ZF)))
>  			printf("\tvmresume set wrong flags\n");
>  		report("test vmresume", 0);
>  		break;
> diff --git a/x86/vmx.h b/x86/vmx.h
> index 1fb9738..d4f979c 100644
> --- a/x86/vmx.h
> +++ b/x86/vmx.h
> @@ -403,10 +403,10 @@ enum Ctrl1 {
>  
>  #define SAVE_RFLAGS		\
>  	"pushf\n\t"			\
> -	"pop regs+0x80\n\t"
> +	"pop host_rflags\n\t"
>  
>  #define LOAD_RFLAGS		\
> -	"push regs+0x80\n\t"	\
> +	"push host_rflags\n\t"	\
>  	"popf\n\t"
>  
>  #define VMX_IO_SIZE_MASK		0x7
> -- 
> 1.7.9.5

--
			Gleb.

  reply	other threads:[~2013-08-05 13:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05 12:43 [PATCH] kvm-unit-tests: VMX: Separate host and guest rflags Arthur Chunqi Li
2013-08-05 13:18 ` Gleb Natapov [this message]
2013-08-05 13:45   ` Arthur Chunqi Li
2013-08-07 15:37 ` 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=20130805131800.GI10891@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.