* [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry
@ 2017-12-13 12:51 Paolo Bonzini
2017-12-13 19:03 ` Jim Mattson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paolo Bonzini @ 2017-12-13 12:51 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: wanpeng.li
xsetbv can be expensive when running on nested virtualization, try to
avoid it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/x86.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0f82e2cbf64c..daa1918031df 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -702,7 +702,8 @@ static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu)
if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) &&
!vcpu->guest_xcr0_loaded) {
/* kvm_set_xcr() also depends on this */
- xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
+ if (vcpu->arch.xcr0 != host_xcr0)
+ xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
vcpu->guest_xcr0_loaded = 1;
}
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry
2017-12-13 12:51 [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry Paolo Bonzini
@ 2017-12-13 19:03 ` Jim Mattson
2017-12-14 1:05 ` Wanpeng Li
2017-12-14 3:27 ` Quan Xu
2 siblings, 0 replies; 4+ messages in thread
From: Jim Mattson @ 2017-12-13 19:03 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: LKML, kvm list, Wanpeng Li
Reviewed-by: Jim Mattson <jmattson@google.com>
On Wed, Dec 13, 2017 at 4:51 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> xsetbv can be expensive when running on nested virtualization, try to
> avoid it.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/kvm/x86.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 0f82e2cbf64c..daa1918031df 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -702,7 +702,8 @@ static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu)
> if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) &&
> !vcpu->guest_xcr0_loaded) {
> /* kvm_set_xcr() also depends on this */
> - xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
> + if (vcpu->arch.xcr0 != host_xcr0)
> + xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
> vcpu->guest_xcr0_loaded = 1;
> }
> }
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry
2017-12-13 12:51 [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry Paolo Bonzini
2017-12-13 19:03 ` Jim Mattson
@ 2017-12-14 1:05 ` Wanpeng Li
2017-12-14 3:27 ` Quan Xu
2 siblings, 0 replies; 4+ messages in thread
From: Wanpeng Li @ 2017-12-14 1:05 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: linux-kernel, kvm, Wanpeng Li
2017-12-13 20:51 GMT+08:00 Paolo Bonzini <pbonzini@redhat.com>:
> xsetbv can be expensive when running on nested virtualization, try to
> avoid it.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> arch/x86/kvm/x86.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 0f82e2cbf64c..daa1918031df 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -702,7 +702,8 @@ static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu)
> if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) &&
> !vcpu->guest_xcr0_loaded) {
> /* kvm_set_xcr() also depends on this */
> - xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
> + if (vcpu->arch.xcr0 != host_xcr0)
> + xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
> vcpu->guest_xcr0_loaded = 1;
> }
> }
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry
2017-12-13 12:51 [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry Paolo Bonzini
2017-12-13 19:03 ` Jim Mattson
2017-12-14 1:05 ` Wanpeng Li
@ 2017-12-14 3:27 ` Quan Xu
2 siblings, 0 replies; 4+ messages in thread
From: Quan Xu @ 2017-12-14 3:27 UTC (permalink / raw)
To: Paolo Bonzini, linux-kernel, kvm; +Cc: wanpeng.li
On 2017/12/13 20:51, Paolo Bonzini wrote:
> xsetbv can be expensive when running on nested virtualization, try to
> avoid it.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/kvm/x86.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 0f82e2cbf64c..daa1918031df 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -702,7 +702,8 @@ static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu)
> if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) &&
> !vcpu->guest_xcr0_loaded) {
> /* kvm_set_xcr() also depends on this */
> - xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
> + if (vcpu->arch.xcr0 != host_xcr0)
> + xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
> vcpu->guest_xcr0_loaded = 1;
> }
> }
Reviewed-by: Quan Xu <quan.xu0@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-14 3:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 12:51 [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry Paolo Bonzini
2017-12-13 19:03 ` Jim Mattson
2017-12-14 1:05 ` Wanpeng Li
2017-12-14 3:27 ` Quan Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.