From: Gleb Natapov <gleb@kernel.org>
To: Dennis Chen <kernel.org.gnu@gmail.com>
Cc: linux-kernel@vger.kernel.org, avi@qumranet.com,
yaniv@qumranet.com, wanpeng.li@linux.intel.com
Subject: Re: [PATCH] KVM-Use value reading from MSR when construct the eptp in VMX mode
Date: Sun, 24 Aug 2014 12:38:00 +0300 [thread overview]
Message-ID: <20140824093759.GG18167@minantech.com> (raw)
In-Reply-To: <CA+U0gVjxF+o3xHPULUQ26wJs4myW3gxUODnUJ3xaYVT6-mFYdg@mail.gmail.com>
On Sun, Aug 24, 2014 at 11:54:32AM +0800, Dennis Chen wrote:
> This patch is used to construct the eptp in vmx mode with values
> readed from MSR according to the intel x86 software developer's
> manual.
>
> Signed-off-by: Dennis Chen <kernel.org.gnu@gmail.com>
> ---
> arch/x86/include/asm/vmx.h | 1 +
> arch/x86/kvm/vmx.c | 21 +++++++++++++++++----
> 2 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
> index bcbfade..bf82a77 100644
> --- a/arch/x86/include/asm/vmx.h
> +++ b/arch/x86/include/asm/vmx.h
> @@ -417,6 +417,7 @@ enum vmcs_field {
> #define VMX_EPT_GAW_EPTP_SHIFT 3
> #define VMX_EPT_AD_ENABLE_BIT (1ull << 6)
> #define VMX_EPT_DEFAULT_MT 0x6ull
> +#define VMX_EPT_UC_MT 0x0ull
> #define VMX_EPT_READABLE_MASK 0x1ull
> #define VMX_EPT_WRITABLE_MASK 0x2ull
> #define VMX_EPT_EXECUTABLE_MASK 0x4ull
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index bfe11cf..7add5ce 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3477,11 +3477,24 @@ static void vmx_set_cr0(struct kvm_vcpu *vcpu,
> unsigned long cr0)
>
> static u64 construct_eptp(unsigned long root_hpa)
> {
> - u64 eptp;
> + u64 eptp, pwl;
> +
> + if (cpu_has_vmx_ept_4levels())
> + pwl = VMX_EPT_DEFAULT_GAW << VMX_EPT_GAW_EPTP_SHIFT;
> + else {
> + WARN(1, "Unsupported page-walk length of 4.\n");
Page-walk length of 4 is the only one that is supported.
> + BUG();
> + }
> +
> + if (cpu_has_vmx_eptp_writeback())
> + eptp = VMX_EPT_DEFAULT_MT | pwl;
> + else if (cpu_has_vmx_eptp_uncacheable())
> + eptp = VMX_EPT_UC_MT | pwl;
> + else {
> + WARN(1, "Unsupported memory type config in vmx eptp.\n");
> + BUG();
> + }
>
> - /* TODO write the value reading from MSR */
> - eptp = VMX_EPT_DEFAULT_MT |
> - VMX_EPT_DEFAULT_GAW << VMX_EPT_GAW_EPTP_SHIFT;
> if (enable_ept_ad_bits)
> eptp |= VMX_EPT_AD_ENABLE_BIT;
> eptp |= (root_hpa & PAGE_MASK);
> --
> 1.7.9.5
--
Gleb.
next prev parent reply other threads:[~2014-08-24 9:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-24 3:54 [PATCH] KVM-Use value reading from MSR when construct the eptp in VMX mode Dennis Chen
2014-08-24 4:19 ` Dennis Chen
2014-08-24 9:38 ` Gleb Natapov [this message]
2014-08-25 3:16 ` Dennis Chen
2014-08-25 14:04 ` Gleb Natapov
2014-08-26 2:34 ` Dennis Chen
2014-08-24 23:14 ` Wanpeng Li
2014-08-25 3:21 ` Dennis Chen
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=20140824093759.GG18167@minantech.com \
--to=gleb@kernel.org \
--cc=avi@qumranet.com \
--cc=kernel.org.gnu@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wanpeng.li@linux.intel.com \
--cc=yaniv@qumranet.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