All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Restore update of required xstate size in guest's CPUID
@ 2020-05-08 23:37 Sean Christopherson
  2020-05-09  2:09 ` Xiaoyao Li
  2020-05-09 12:51 ` Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2020-05-08 23:37 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, kvm, linux-kernel, Xiaoyao Li

Restore a guest CPUID update that was unintentional collateral damage
when the per-vCPU guest_xstate_size field was removed.

Cc: Xiaoyao Li <xiaoyao.li@intel.com>
Fixes: d87277414b851 ("kvm: x86: Cleanup vcpu->arch.guest_xstate_size")
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---

There's nothing more thrilling than watching bisect home in on your own
commits, only to land on someone else's on the very last step.

 arch/x86/kvm/cpuid.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 35845704cf57a..cd708b0b460a0 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -84,11 +84,13 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
 				   kvm_read_cr4_bits(vcpu, X86_CR4_PKE));
 
 	best = kvm_find_cpuid_entry(vcpu, 0xD, 0);
-	if (!best)
+	if (!best) {
 		vcpu->arch.guest_supported_xcr0 = 0;
-	else
+	} else {
 		vcpu->arch.guest_supported_xcr0 =
 			(best->eax | ((u64)best->edx << 32)) & supported_xcr0;
+		best->ebx = xstate_required_size(vcpu->arch.xcr0, false);
+	}
 
 	best = kvm_find_cpuid_entry(vcpu, 0xD, 1);
 	if (best && (cpuid_entry_has(best, X86_FEATURE_XSAVES) ||
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86: Restore update of required xstate size in guest's CPUID
  2020-05-08 23:37 [PATCH] KVM: x86: Restore update of required xstate size in guest's CPUID Sean Christopherson
@ 2020-05-09  2:09 ` Xiaoyao Li
  2020-05-09 12:51 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Xiaoyao Li @ 2020-05-09  2:09 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: Vitaly Kuznetsov, Wanpeng Li, Jim Mattson, Joerg Roedel, kvm,
	linux-kernel

On 5/9/2020 7:37 AM, Sean Christopherson wrote:
> Restore a guest CPUID update that was unintentional collateral damage
> when the per-vCPU guest_xstate_size field was removed.

It's really unintentional. None of us noticed it. :(

It's good that you catch it!

> Cc: Xiaoyao Li <xiaoyao.li@intel.com>
> Fixes: d87277414b851 ("kvm: x86: Cleanup vcpu->arch.guest_xstate_size")
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
> 
> There's nothing more thrilling than watching bisect home in on your own
> commits, only to land on someone else's on the very last step.
> 
>   arch/x86/kvm/cpuid.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 35845704cf57a..cd708b0b460a0 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -84,11 +84,13 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
>   				   kvm_read_cr4_bits(vcpu, X86_CR4_PKE));
>   
>   	best = kvm_find_cpuid_entry(vcpu, 0xD, 0);
> -	if (!best)
> +	if (!best) {
>   		vcpu->arch.guest_supported_xcr0 = 0;
> -	else
> +	} else {
>   		vcpu->arch.guest_supported_xcr0 =
>   			(best->eax | ((u64)best->edx << 32)) & supported_xcr0;
> +		best->ebx = xstate_required_size(vcpu->arch.xcr0, false);
> +	}
>   
>   	best = kvm_find_cpuid_entry(vcpu, 0xD, 1);
>   	if (best && (cpuid_entry_has(best, X86_FEATURE_XSAVES) ||
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86: Restore update of required xstate size in guest's CPUID
  2020-05-08 23:37 [PATCH] KVM: x86: Restore update of required xstate size in guest's CPUID Sean Christopherson
  2020-05-09  2:09 ` Xiaoyao Li
@ 2020-05-09 12:51 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-05-09 12:51 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Vitaly Kuznetsov, Wanpeng Li, Jim Mattson, Joerg Roedel, kvm,
	linux-kernel, Xiaoyao Li

On 09/05/20 01:37, Sean Christopherson wrote:
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 35845704cf57a..cd708b0b460a0 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -84,11 +84,13 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
>  				   kvm_read_cr4_bits(vcpu, X86_CR4_PKE));
>  
>  	best = kvm_find_cpuid_entry(vcpu, 0xD, 0);
> -	if (!best)
> +	if (!best) {
>  		vcpu->arch.guest_supported_xcr0 = 0;
> -	else
> +	} else {
>  		vcpu->arch.guest_supported_xcr0 =
>  			(best->eax | ((u64)best->edx << 32)) & supported_xcr0;
> +		best->ebx = xstate_required_size(vcpu->arch.xcr0, false);
> +	}
>  
>  	best = kvm_find_cpuid_entry(vcpu, 0xD, 1);
>  	if (best && (cpuid_entry_has(best, X86_FEATURE_XSAVES) ||
> -- 2.26.0

Ugh, I'll write a testcase as penance.  Squashed, thanks.

Paolo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-09 12:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 23:37 [PATCH] KVM: x86: Restore update of required xstate size in guest's CPUID Sean Christopherson
2020-05-09  2:09 ` Xiaoyao Li
2020-05-09 12:51 ` Paolo Bonzini

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.