* [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb
@ 2018-12-06 7:34 lantianyu1986
2018-12-06 7:34 ` [PATCH V2 2/2] KVM/VMX: Fix max line length problem in the vmx_hv_remote_flush_tlb() lantianyu1986
2018-12-14 11:00 ` [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb Paolo Bonzini
0 siblings, 2 replies; 4+ messages in thread
From: lantianyu1986 @ 2018-12-06 7:34 UTC (permalink / raw)
Cc: Lan Tianyu, pbonzini, rkrcmar, tglx, mingo, bp, hpa, x86, kvm,
linux-kernel, michael.h.kelley, kys, vkuznets
From: Lan Tianyu <Tianyu.Lan@microsoft.com>
This patch is to initialize ept_pointer to INVALID_PAGE and check it
before flushing ept tlb. If ept_pointer is invalid, bypass the flush
request.
Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
---
arch/x86/kvm/vmx.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c379d0bfdcba..6577ec8cbb0f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1582,11 +1582,18 @@ static int vmx_hv_remote_flush_tlb(struct kvm *kvm)
/*
* FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE hypercall needs the address of the
* base of EPT PML4 table, strip off EPT configuration information.
+ * If ept_pointer is invalid pointer, bypass the flush request.
*/
if (to_kvm_vmx(kvm)->ept_pointers_match != EPT_POINTERS_MATCH) {
- kvm_for_each_vcpu(i, vcpu, kvm)
+ kvm_for_each_vcpu(i, vcpu, kvm) {
+ u64 ept_pointer = to_vmx(vcpu)->ept_pointer;
+
+ if (!VALID_PAGE(ept_pointer))
+ continue;
+
ret |= hyperv_flush_guest_mapping(
- to_vmx(kvm_get_vcpu(kvm, i))->ept_pointer & PAGE_MASK);
+ ept_pointer & PAGE_MASK);
+ }
} else {
ret = hyperv_flush_guest_mapping(
to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer & PAGE_MASK);
@@ -11614,6 +11621,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
vmx->pi_desc.nv = POSTED_INTR_VECTOR;
vmx->pi_desc.sn = 1;
+ vmx->ept_pointer = INVALID_PAGE;
+
return &vmx->vcpu;
free_vmcs:
--
2.14.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH V2 2/2] KVM/VMX: Fix max line length problem in the vmx_hv_remote_flush_tlb()
2018-12-06 7:34 [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb lantianyu1986
@ 2018-12-06 7:34 ` lantianyu1986
2018-12-14 11:00 ` [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb Paolo Bonzini
1 sibling, 0 replies; 4+ messages in thread
From: lantianyu1986 @ 2018-12-06 7:34 UTC (permalink / raw)
Cc: Lan Tianyu, pbonzini, rkrcmar, tglx, mingo, bp, hpa, x86, kvm,
linux-kernel, michael.h.kelley, kys, vkuznets
From: Lan Tianyu <Tianyu.Lan@microsoft.com>
Fix max line length problem.
Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
---
arch/x86/kvm/vmx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 6577ec8cbb0f..2356118ea440 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1596,7 +1596,7 @@ static int vmx_hv_remote_flush_tlb(struct kvm *kvm)
}
} else {
ret = hyperv_flush_guest_mapping(
- to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer & PAGE_MASK);
+ to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer & PAGE_MASK);
}
spin_unlock(&to_kvm_vmx(kvm)->ept_pointer_lock);
--
2.14.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb
2018-12-06 7:34 [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb lantianyu1986
2018-12-06 7:34 ` [PATCH V2 2/2] KVM/VMX: Fix max line length problem in the vmx_hv_remote_flush_tlb() lantianyu1986
@ 2018-12-14 11:00 ` Paolo Bonzini
2018-12-17 14:08 ` Tianyu Lan
1 sibling, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2018-12-14 11:00 UTC (permalink / raw)
To: lantianyu1986
Cc: Lan Tianyu, rkrcmar, tglx, mingo, bp, hpa, x86, kvm,
linux-kernel, michael.h.kelley, kys, vkuznets
On 06/12/18 08:34, lantianyu1986@gmail.com wrote:
> From: Lan Tianyu <Tianyu.Lan@microsoft.com>
>
> This patch is to initialize ept_pointer to INVALID_PAGE and check it
> before flushing ept tlb. If ept_pointer is invalid, bypass the flush
> request.
>
> Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
Can you explain better *why* this patch is needed? Also, should
vmx->ept_pointer be cleared at reset time, rather than vCPU creation?
Thanks,
Paolo
> ---
> arch/x86/kvm/vmx.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index c379d0bfdcba..6577ec8cbb0f 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -1582,11 +1582,18 @@ static int vmx_hv_remote_flush_tlb(struct kvm *kvm)
> /*
> * FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE hypercall needs the address of the
> * base of EPT PML4 table, strip off EPT configuration information.
> + * If ept_pointer is invalid pointer, bypass the flush request.
> */
> if (to_kvm_vmx(kvm)->ept_pointers_match != EPT_POINTERS_MATCH) {
> - kvm_for_each_vcpu(i, vcpu, kvm)
> + kvm_for_each_vcpu(i, vcpu, kvm) {
> + u64 ept_pointer = to_vmx(vcpu)->ept_pointer;
> +
> + if (!VALID_PAGE(ept_pointer))
> + continue;
> +
> ret |= hyperv_flush_guest_mapping(
> - to_vmx(kvm_get_vcpu(kvm, i))->ept_pointer & PAGE_MASK);
> + ept_pointer & PAGE_MASK);
> + }
> } else {
> ret = hyperv_flush_guest_mapping(
> to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer & PAGE_MASK);
> @@ -11614,6 +11621,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
> vmx->pi_desc.nv = POSTED_INTR_VECTOR;
> vmx->pi_desc.sn = 1;
>
> + vmx->ept_pointer = INVALID_PAGE;
> +
> return &vmx->vcpu;
>
> free_vmcs:
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb
2018-12-14 11:00 ` [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb Paolo Bonzini
@ 2018-12-17 14:08 ` Tianyu Lan
0 siblings, 0 replies; 4+ messages in thread
From: Tianyu Lan @ 2018-12-17 14:08 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Lan Tianyu, Radim Krcmar, Thomas Gleixner, Ingo Molnar, bp,
H. Peter Anvin, the arch/x86 maintainers, kvm,
linux-kernel@vger kernel org, michael.h.kelley, kys, vkuznets
On Fri, Dec 14, 2018 at 7:00 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 06/12/18 08:34, lantianyu1986@gmail.com wrote:
> > From: Lan Tianyu <Tianyu.Lan@microsoft.com>
> >
> > This patch is to initialize ept_pointer to INVALID_PAGE and check it
> > before flushing ept tlb. If ept_pointer is invalid, bypass the flush
> > request.
> >
> > Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
>
> Can you explain better *why* this patch is needed?
Yes, hypercall still maybe called when ept_pointers aren't
initialized. Such case happens
during guest boot up when BP works at first and APs aren't activated.
> Also, should vmx->ept_pointer be cleared at reset time, rather than vCPU creation?
>
Yes, that make sense. Thanks for suggestion.
> Thanks,
>
> Paolo
>
> > ---
> > arch/x86/kvm/vmx.c | 13 +++++++++++--
> > 1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> > index c379d0bfdcba..6577ec8cbb0f 100644
> > --- a/arch/x86/kvm/vmx.c
> > +++ b/arch/x86/kvm/vmx.c
> > @@ -1582,11 +1582,18 @@ static int vmx_hv_remote_flush_tlb(struct kvm *kvm)
> > /*
> > * FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE hypercall needs the address of the
> > * base of EPT PML4 table, strip off EPT configuration information.
> > + * If ept_pointer is invalid pointer, bypass the flush request.
> > */
> > if (to_kvm_vmx(kvm)->ept_pointers_match != EPT_POINTERS_MATCH) {
> > - kvm_for_each_vcpu(i, vcpu, kvm)
> > + kvm_for_each_vcpu(i, vcpu, kvm) {
> > + u64 ept_pointer = to_vmx(vcpu)->ept_pointer;
> > +
> > + if (!VALID_PAGE(ept_pointer))
> > + continue;
> > +
> > ret |= hyperv_flush_guest_mapping(
> > - to_vmx(kvm_get_vcpu(kvm, i))->ept_pointer & PAGE_MASK);
> > + ept_pointer & PAGE_MASK);
> > + }
> > } else {
> > ret = hyperv_flush_guest_mapping(
> > to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer & PAGE_MASK);
> > @@ -11614,6 +11621,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
> > vmx->pi_desc.nv = POSTED_INTR_VECTOR;
> > vmx->pi_desc.sn = 1;
> >
> > + vmx->ept_pointer = INVALID_PAGE;
> > +
> > return &vmx->vcpu;
> >
> > free_vmcs:
> >
>
--
Best regards
Tianyu Lan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-17 14:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06 7:34 [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb lantianyu1986
2018-12-06 7:34 ` [PATCH V2 2/2] KVM/VMX: Fix max line length problem in the vmx_hv_remote_flush_tlb() lantianyu1986
2018-12-14 11:00 ` [PATCH V2 1/2] KVM/VMX: Check ept_pointer before flushing ept tlb Paolo Bonzini
2018-12-17 14:08 ` Tianyu Lan
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).