Patchwork [v2,2/2] kvm: x86: Clear {ebx,ecx,edx} from CPUID leaf 9

login
register
mail settings
Submitter Jim Mattson
Date Feb. 8, 2019, 9:45 p.m.
Message ID <20190208214557.5735-2-jmattson@google.com>
Download mbox | patch
Permalink /patch/721951/
State New
Headers show

Comments

Jim Mattson - Feb. 8, 2019, 9:45 p.m.
According to volume 2 of the SDM, output registers %ebx, %ecx, and
%edx of CPUID leaf 9 (the direct cache access information leaf) are
reserved.  Since we have no way of knowing what these fields will be
used for, they should not be whitelisted.

Fixes: 24c82e576b78 ("KVM: Sanitize cpuid")
Suggested-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
---
 arch/x86/kvm/cpuid.c | 1 +
 1 file changed, 1 insertion(+)
Christopherson, Sean J - Feb. 8, 2019, 9:59 p.m.
On Fri, Feb 08, 2019 at 01:45:57PM -0800, Jim Mattson wrote:
> According to volume 2 of the SDM, output registers %ebx, %ecx, and
> %edx of CPUID leaf 9 (the direct cache access information leaf) are
> reserved.  Since we have no way of knowing what these fields will be
> used for, they should not be whitelisted.
> 
> Fixes: 24c82e576b78 ("KVM: Sanitize cpuid")
> Suggested-by: Sean Christopherson <sean.j.christopherson@intel.com>
> Signed-off-by: Jim Mattson <jmattson@google.com>

Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

> ---
>  arch/x86/kvm/cpuid.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 183f40cd3362..d9b6d90fd062 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -510,6 +510,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>  		break;
>  	}
>  	case 9:
> +		entry->ebx = entry->ecx = entry->edx = 0;
>  		break;
>  	case 0xa: { /* Architectural Performance Monitoring */
>  		struct x86_pmu_capability cap;
> -- 
> 2.20.1.791.gb4d0f1c61a-goog
>

Patch

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 183f40cd3362..d9b6d90fd062 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -510,6 +510,7 @@  static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 		break;
 	}
 	case 9:
+		entry->ebx = entry->ecx = entry->edx = 0;
 		break;
 	case 0xa: { /* Architectural Performance Monitoring */
 		struct x86_pmu_capability cap;