From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <wanpeng.li@linux.intel.com>
Cc: Nadav Amit <nadav.amit@gmail.com>,
rkrcmar@redhat.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] kvm: vmx: add nested virtualization support for xsaves
Date: Thu, 04 Dec 2014 15:17:03 +0100 [thread overview]
Message-ID: <54806CDF.50609@redhat.com> (raw)
In-Reply-To: <1417691470-5221-1-git-send-email-wanpeng.li@linux.intel.com>
On 04/12/2014 12:11, Wanpeng Li wrote:
> Add nested virtualization support for xsaves.
>
> Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
> ---
> arch/x86/kvm/vmx.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 6e3a448..e5bc349 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -216,6 +216,7 @@ struct __packed vmcs12 {
> u64 virtual_apic_page_addr;
> u64 apic_access_addr;
> u64 ept_pointer;
> + u64 xss_exit_bitmap;
> u64 guest_physical_address;
> u64 vmcs_link_pointer;
> u64 guest_ia32_debugctl;
> @@ -618,6 +619,7 @@ static const unsigned short vmcs_field_to_offset_table[] = {
> FIELD64(VIRTUAL_APIC_PAGE_ADDR, virtual_apic_page_addr),
> FIELD64(APIC_ACCESS_ADDR, apic_access_addr),
> FIELD64(EPT_POINTER, ept_pointer),
> + FIELD64(XSS_EXIT_BITMAP, xss_exit_bitmap),
> FIELD64(GUEST_PHYSICAL_ADDRESS, guest_physical_address),
> FIELD64(VMCS_LINK_POINTER, vmcs_link_pointer),
> FIELD64(GUEST_IA32_DEBUGCTL, guest_ia32_debugctl),
> @@ -1104,6 +1106,12 @@ static inline int nested_cpu_has_ept(struct vmcs12 *vmcs12)
> return nested_cpu_has2(vmcs12, SECONDARY_EXEC_ENABLE_EPT);
> }
>
> +static inline bool nested_cpu_has_xsaves(struct vmcs12 *vmcs12)
> +{
> + return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES) &&
> + vmx_xsaves_supported();
> +}
> +
> static inline bool is_exception(u32 intr_info)
> {
> return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VALID_MASK))
> @@ -2392,7 +2400,8 @@ static __init void nested_vmx_setup_ctls_msrs(void)
> nested_vmx_secondary_ctls_high &=
> SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
> SECONDARY_EXEC_UNRESTRICTED_GUEST |
> - SECONDARY_EXEC_WBINVD_EXITING;
> + SECONDARY_EXEC_WBINVD_EXITING |
> + SECONDARY_EXEC_XSAVES;
>
> if (enable_ept) {
> /* nested EPT: emulate EPT also to L1 */
> @@ -7285,6 +7294,8 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
> return nested_cpu_has2(vmcs12, SECONDARY_EXEC_WBINVD_EXITING);
> case EXIT_REASON_XSETBV:
> return 1;
> + case EXIT_REASON_XSAVES: case EXIT_REASON_XRSTORS:
> + return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES);
This assumes that we do not set any bit in the XSS exit bitmap in the
host, and/or that we do not allow setting any bit in the XSS msr itself.
Otherwise we'd have to check the XSS MSR of the L2 guest against the
exit bitmap of the guest.
I'll add a FIXME here.
Paolo
> default:
> return 1;
> }
> @@ -8341,6 +8352,8 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
> vmcs_writel(GUEST_SYSENTER_ESP, vmcs12->guest_sysenter_esp);
> vmcs_writel(GUEST_SYSENTER_EIP, vmcs12->guest_sysenter_eip);
>
> + if (nested_cpu_has_xsaves(vmcs12))
> + vmcs_write64(XSS_EXIT_BITMAP, vmcs12->xss_exit_bitmap);
> vmcs_write64(VMCS_LINK_POINTER, -1ull);
>
> exec_control = vmcs12->pin_based_vm_exec_control;
> @@ -8981,6 +8994,8 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
> vmcs12->guest_sysenter_eip = vmcs_readl(GUEST_SYSENTER_EIP);
> if (vmx_mpx_supported())
> vmcs12->guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS);
> + if (nested_cpu_has_xsaves(vmcs12))
> + vmcs12->xss_exit_bitmap = vmcs_read64(XSS_EXIT_BITMAP);
>
> /* update exit information fields: */
>
>
prev parent reply other threads:[~2014-12-04 14:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-04 11:11 [PATCH v2 1/4] kvm: vmx: add nested virtualization support for xsaves Wanpeng Li
2014-12-04 11:11 ` [PATCH v2 2/4] kvm: cpuid: fix the size of xsaves area Wanpeng Li
2014-12-04 13:14 ` Radim Krčmář
2014-12-04 15:49 ` Paolo Bonzini
2014-12-04 16:41 ` Radim Krčmář
2014-12-04 11:11 ` [PATCH v2 3/4] kvm: cpuid: fix xsave area size of XSAVEC Wanpeng Li
2014-12-04 13:19 ` Radim Krčmář
2014-12-04 11:11 ` [PATCH v2 4/4] kvm: vmx: fix VMfailValid when write vmcs02/vmcs01 Wanpeng Li
2014-12-04 14:28 ` Paolo Bonzini
2014-12-04 14:17 ` 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=54806CDF.50609@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nadav.amit@gmail.com \
--cc=rkrcmar@redhat.com \
--cc=wanpeng.li@linux.intel.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;
as well as URLs for NNTP newsgroup(s).