Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1231905 > unrolled thread

[PATCH] KVM: nVMX: expose VPID capability to L1

Started byWanpeng Li <wanpeng.li@hotmail.com>
First post2015-09-24 09:10 +0200
Last post2015-09-29 11:10 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] KVM: nVMX: expose VPID capability to L1  Wanpeng Li <wanpeng.li@hotmail.com> - 2015-09-24 09:10 +0200
    Re: [PATCH] KVM: nVMX: expose VPID capability to L1 Paolo Bonzini <pbonzini@redhat.com> - 2015-09-28 14:10 +0200
      Re: [PATCH] KVM: nVMX: expose VPID capability to L1 Wanpeng Li <wanpeng.li@hotmail.com> - 2015-09-29 03:20 +0200
        Re: [PATCH] KVM: nVMX: expose VPID capability to L1 Paolo Bonzini <pbonzini@redhat.com> - 2015-09-29 11:10 +0200

#1231905 — [PATCH] KVM: nVMX: expose VPID capability to L1

FromWanpeng Li <wanpeng.li@hotmail.com>
Date2015-09-24 09:10 +0200
Subject[PATCH] KVM: nVMX: expose VPID capability to L1
Message-ID<qc8Pf-4iI-5@gated-at.bofh.it>
Expose VPID capability to L1.

Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
 arch/x86/kvm/vmx.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f9219ad..866045c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -442,7 +442,7 @@ struct nested_vmx {
 	u32 nested_vmx_true_entry_ctls_low;
 	u32 nested_vmx_misc_low;
 	u32 nested_vmx_misc_high;
-	u32 nested_vmx_ept_caps;
+	u64 nested_vmx_ept_vpid_caps;
 };
 
 #define POSTED_INTR_ON  0
@@ -2485,22 +2485,23 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
 		SECONDARY_EXEC_WBINVD_EXITING |
 		SECONDARY_EXEC_XSAVES;
 
-	if (enable_ept) {
+	if (enable_ept | enable_vpid) {
 		/* nested EPT: emulate EPT also to L1 */
 		vmx->nested.nested_vmx_secondary_ctls_high |=
 			SECONDARY_EXEC_ENABLE_EPT;
-		vmx->nested.nested_vmx_ept_caps = VMX_EPT_PAGE_WALK_4_BIT |
+		vmx->nested.nested_vmx_ept_vpid_caps = VMX_EPT_PAGE_WALK_4_BIT |
 			 VMX_EPTP_WB_BIT | VMX_EPT_2MB_PAGE_BIT |
 			 VMX_EPT_INVEPT_BIT;
-		vmx->nested.nested_vmx_ept_caps &= vmx_capability.ept;
+		vmx->nested.nested_vmx_ept_vpid_caps &= vmx_capability.ept;
 		/*
 		 * For nested guests, we don't do anything specific
 		 * for single context invalidation. Hence, only advertise
 		 * support for global context invalidation.
 		 */
-		vmx->nested.nested_vmx_ept_caps |= VMX_EPT_EXTENT_GLOBAL_BIT;
+		vmx->nested.nested_vmx_ept_vpid_caps |= VMX_EPT_EXTENT_GLOBAL_BIT;
+		vmx->nested.nested_vmx_ept_vpid_caps |= (unsigned long)vmx_capability.vpid << 32;
 	} else
-		vmx->nested.nested_vmx_ept_caps = 0;
+		vmx->nested.nested_vmx_ept_vpid_caps = 0;
 
 	if (enable_unrestricted_guest)
 		vmx->nested.nested_vmx_secondary_ctls_high |=
@@ -2616,8 +2617,7 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
 			vmx->nested.nested_vmx_secondary_ctls_high);
 		break;
 	case MSR_IA32_VMX_EPT_VPID_CAP:
-		/* Currently, no nested vpid support */
-		*pdata = vmx->nested.nested_vmx_ept_caps;
+		*pdata = vmx->nested.nested_vmx_ept_vpid_caps;
 		break;
 	default:
 		return 1;
@@ -7152,7 +7152,7 @@ static int handle_invept(struct kvm_vcpu *vcpu)
 
 	if (!(vmx->nested.nested_vmx_secondary_ctls_high &
 	      SECONDARY_EXEC_ENABLE_EPT) ||
-	    !(vmx->nested.nested_vmx_ept_caps & VMX_EPT_INVEPT_BIT)) {
+	    !(vmx->nested.nested_vmx_ept_vpid_caps & VMX_EPT_INVEPT_BIT)) {
 		kvm_queue_exception(vcpu, UD_VECTOR);
 		return 1;
 	}
@@ -7168,7 +7168,7 @@ static int handle_invept(struct kvm_vcpu *vcpu)
 	vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);
 	type = kvm_register_readl(vcpu, (vmx_instruction_info >> 28) & 0xf);
 
-	types = (vmx->nested.nested_vmx_ept_caps >> VMX_EPT_EXTENT_SHIFT) & 6;
+	types = (vmx->nested.nested_vmx_ept_vpid_caps >> VMX_EPT_EXTENT_SHIFT) & 6;
 
 	if (!(types & (1UL << type))) {
 		nested_vmx_failValid(vcpu,
@@ -8772,7 +8772,7 @@ static void nested_ept_init_mmu_context(struct kvm_vcpu *vcpu)
 {
 	WARN_ON(mmu_is_nested(vcpu));
 	kvm_init_shadow_ept_mmu(vcpu,
-			to_vmx(vcpu)->nested.nested_vmx_ept_caps &
+			to_vmx(vcpu)->nested.nested_vmx_ept_vpid_caps &
 			VMX_EPT_EXECUTE_ONLY_BIT);
 	vcpu->arch.mmu.set_cr3           = vmx_set_cr3;
 	vcpu->arch.mmu.get_cr3           = nested_ept_get_cr3;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1234070

FromPaolo Bonzini <pbonzini@redhat.com>
Date2015-09-28 14:10 +0200
Message-ID<qdFpL-5fT-3@gated-at.bofh.it>
In reply to#1231905

On 24/09/2015 08:51, Wanpeng Li wrote:
>  		/*
>  		 * For nested guests, we don't do anything specific
>  		 * for single context invalidation. Hence, only advertise
>  		 * support for global context invalidation.
>  		 */
> -		vmx->nested.nested_vmx_ept_caps |= VMX_EPT_EXTENT_GLOBAL_BIT;
> +		vmx->nested.nested_vmx_ept_vpid_caps |= VMX_EPT_EXTENT_GLOBAL_BIT;
> +		vmx->nested.nested_vmx_ept_vpid_caps |= (unsigned long)vmx_capability.vpid << 32;

Hi Wanpeng, the comment above is about invept, but the same applies
applies to invvpid.  We can set only VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1234625

FromWanpeng Li <wanpeng.li@hotmail.com>
Date2015-09-29 03:20 +0200
Message-ID<qdRKi-8ei-7@gated-at.bofh.it>
In reply to#1234070
On 9/28/15 8:05 PM, Paolo Bonzini wrote:
>
> On 24/09/2015 08:51, Wanpeng Li wrote:
>>   		/*
>>   		 * For nested guests, we don't do anything specific
>>   		 * for single context invalidation. Hence, only advertise
>>   		 * support for global context invalidation.
>>   		 */
>> -		vmx->nested.nested_vmx_ept_caps |= VMX_EPT_EXTENT_GLOBAL_BIT;
>> +		vmx->nested.nested_vmx_ept_vpid_caps |= VMX_EPT_EXTENT_GLOBAL_BIT;
>> +		vmx->nested.nested_vmx_ept_vpid_caps |= (unsigned long)vmx_capability.vpid << 32;
> Hi Wanpeng, the comment above is about invept, but the same applies
> applies to invvpid.  We can set only VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT.

Agreed. I see the patch has already in kvm/queue, if I need to send out 
another patch or you can adjust it for me? :-)

Regards,
Wanpeng Li
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1234879

FromPaolo Bonzini <pbonzini@redhat.com>
Date2015-09-29 11:10 +0200
Message-ID<qdZ58-1ZA-5@gated-at.bofh.it>
In reply to#1234625

On 29/09/2015 03:15, Wanpeng Li wrote:
>>>
>> Hi Wanpeng, the comment above is about invept, but the same applies
>> applies to invvpid.  We can set only VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT.
> 
> Agreed. I see the patch has already in kvm/queue, if I need to send out
> another patch or you can adjust it for me? :-)

Please resend the patch.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web