public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Arthur Chunqi Li <yzt356@gmail.com>
Cc: kvm@vger.kernel.org, jan.kiszka@web.de, gleb@redhat.com
Subject: Re: [PATCH v4 2/2] kvm-unit-tests : The first version of VMX nested test case
Date: Wed, 17 Jul 2013 12:13:54 +0200	[thread overview]
Message-ID: <51E66E62.3010205@redhat.com> (raw)
In-Reply-To: <1374041153-32235-3-git-send-email-yzt356@gmail.com>

Il 17/07/2013 08:05, Arthur Chunqi Li ha scritto:
> +	guest_rip = vmcs_read(GUEST_RIP);
> +	reason = vmcs_read(EXI_REASON) & 0xff;
> +
> +	switch (reason) {
> +	case VMX_VMCALL:
> +		print_vmexit_info();
> +		vmcs_write(GUEST_RIP, guest_rip + 3);
> +		goto vmx_resume;
> +	case VMX_HLT:
> +		goto vmx_halt;
> +	default:
> +		break;
> +	}

Could you reorganize this code, so that it reuses the switch statement
you have in the "current != NULL && current->exit_handler != NULL" case?

In other words, it looks like this code:

> +	if ((read_cr4() & CR4_PAE) && (read_cr0() & CR0_PG)
> +		&& !(rdmsr(MSR_EFER) & EFER_LMA))
> +		printf("ERROR : PDPTEs should be checked\n");
> +
> +	guest_rip = vmcs_read(GUEST_RIP);
> +	reason = vmcs_read(EXI_REASON) & 0xff;
> +
> +	switch (reason) {
> +	case VMX_VMCALL:
> +		print_vmexit_info();
> +		vmcs_write(GUEST_RIP, guest_rip + 3);
> +		goto vmx_resume;
> +	case VMX_HLT:
> +		goto vmx_halt;
> +	default:
> +		break;
> +	}
> +	printf("ERROR : Unhandled vmx exit.\n");
> +	print_vmexit_info();

is only alternative to this:

> +		current->exits ++;
> +		current->guest_regs = regs;
> +		ret = current->exit_handler();
> +		regs = current->guest_regs;

Everything that comes after "regs = current->guest_regs;" should be
outside the "if".  Please tell me if I'm not clear. :)

> +#define VMX_HALT	1
> +#define VMX_EXIT	2
> +#define VMX_RESUME	3

These are not VMX constants, so perhaps you can rename them to
VMXTEST_{HANDLE,EXIT,RESUME}?

Paolo

  parent reply	other threads:[~2013-07-17 10:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17  6:05 [PATCH v4 0/2] Basic nested VMX test suite Arthur Chunqi Li
2013-07-17  6:05 ` [PATCH v4 1/2] kvm-unit-tests : Add setjmp/longjmp to libcflat Arthur Chunqi Li
2013-07-17  6:05 ` [PATCH v4 2/2] kvm-unit-tests : The first version of VMX nested test case Arthur Chunqi Li
2013-07-17  6:26   ` Jan Kiszka
2013-07-17  6:36     ` Arthur Chunqi Li
2013-07-17 10:13   ` Paolo Bonzini [this message]
2013-07-17  6:08 ` [PATCH v4 0/2] Basic nested VMX test suite Arthur Chunqi Li
2013-07-17  6:21   ` Gleb Natapov
2013-07-17  7:52     ` Paolo Bonzini
2013-07-17  9:03       ` Gleb Natapov
2013-07-17 10:19         ` Paolo Bonzini
2013-07-17 10:31           ` Gleb Natapov
2013-07-17 10:46             ` Jan Kiszka
2013-07-17 10:54             ` Paolo Bonzini
2013-07-17 13:48               ` Arthur Chunqi Li
2013-07-17 14:10                 ` 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=51E66E62.3010205@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox