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] kvm-unit-tests: VMX: Fix some nested EPT related bugs
Date: Mon, 09 Sep 2013 18:25:58 +0200 [thread overview]
Message-ID: <522DF696.80901@redhat.com> (raw)
In-Reply-To: <1378742149-30822-1-git-send-email-yzt356@gmail.com>
Il 09/09/2013 17:55, Arthur Chunqi Li ha scritto:
> This patch fix 3 bugs in VMX framework and EPT framework
> 1. Fix bug of setting default value of CPU_SECONDARY
> 2. Fix bug of reading MSR_IA32_VMX_PROCBASED_CTLS2 and
> MSR_IA32_VMX_EPT_VPID_CAP
> 3. For EPT violation and misconfiguration reduced vmexit, vmcs field
> "VM-exit instruction length" is not used and will return unexpected
> value when read.
>
> Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
> ---
> x86/vmx.c | 13 ++++++++++---
> x86/vmx_tests.c | 2 --
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/x86/vmx.c b/x86/vmx.c
> index 87d1d55..9db4ef4 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -304,7 +304,8 @@ static void init_vmcs_ctrl(void)
> /* Disable VMEXIT of IO instruction */
> vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu[0]);
> if (ctrl_cpu_rev[0].set & CPU_SECONDARY) {
> - ctrl_cpu[1] |= ctrl_cpu_rev[1].set & ctrl_cpu_rev[1].clr;
> + ctrl_cpu[1] = (ctrl_cpu[1] | ctrl_cpu_rev[1].set) &
> + ctrl_cpu_rev[1].clr;
> vmcs_write(CPU_EXEC_CTRL1, ctrl_cpu[1]);
> }
> vmcs_write(CR3_TARGET_COUNT, 0);
> @@ -489,8 +490,14 @@ static void init_vmx(void)
> : MSR_IA32_VMX_ENTRY_CTLS);
> ctrl_cpu_rev[0].val = rdmsr(basic.ctrl ? MSR_IA32_VMX_TRUE_PROC
> : MSR_IA32_VMX_PROCBASED_CTLS);
> - ctrl_cpu_rev[1].val = rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2);
> - ept_vpid.val = rdmsr(MSR_IA32_VMX_EPT_VPID_CAP);
> + if ((ctrl_cpu_rev[0].clr & CPU_SECONDARY) != 0)
> + ctrl_cpu_rev[1].val = rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2);
> + else
> + ctrl_cpu_rev[1].val = 0;
> + if ((ctrl_cpu_rev[1].clr & (CPU_EPT | CPU_VPID)) != 0)
> + ept_vpid.val = rdmsr(MSR_IA32_VMX_EPT_VPID_CAP);
> + else
> + ept_vpid.val = 0;
>
> write_cr0((read_cr0() & fix_cr0_clr) | fix_cr0_set);
> write_cr4((read_cr4() & fix_cr4_clr) | fix_cr4_set | X86_CR4_VMXE);
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 6d972c0..e891a9f 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -1075,7 +1075,6 @@ static int ept_exit_handler()
> print_vmexit_info();
> return VMX_TEST_VMEXIT;
> }
> - vmcs_write(GUEST_RIP, guest_rip + insn_len);
> return VMX_TEST_RESUME;
> case VMX_EPT_VIOLATION:
> switch(get_stage()) {
> @@ -1100,7 +1099,6 @@ static int ept_exit_handler()
> print_vmexit_info();
> return VMX_TEST_VMEXIT;
> }
> - vmcs_write(GUEST_RIP, guest_rip + insn_len);
> return VMX_TEST_RESUME;
> default:
> printf("Unknown exit reason, %d\n", reason);
>
Looks good, thanks!
Paolo
prev parent reply other threads:[~2013-09-09 16:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-09 15:55 [PATCH] kvm-unit-tests: VMX: Fix some nested EPT related bugs Arthur Chunqi Li
2013-09-09 16:25 ` 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=522DF696.80901@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