0294-KVM-x86-Add-speculative-control-CPUID-support-for-gu.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Tom Lendacky <[email protected]>
  3. Date: Wed, 20 Dec 2017 10:55:47 +0000
  4. Subject: [PATCH] KVM: x86: Add speculative control CPUID support for guests
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5753
  9. CVE-2017-5715
  10. Provide the guest with the speculative control CPUID related values.
  11. Signed-off-by: Paolo Bonzini <[email protected]>
  12. Signed-off-by: Tom Lendacky <[email protected]>
  13. Signed-off-by: Andy Whitcroft <[email protected]>
  14. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  15. (cherry picked from commit db7641e5f41cd517c4181ce90c4f9ecc93af4b2b)
  16. Signed-off-by: Fabian Grünbichler <[email protected]>
  17. ---
  18. arch/x86/kvm/cpuid.c | 12 ++++++++++--
  19. 1 file changed, 10 insertions(+), 2 deletions(-)
  20. diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
  21. index 19adbb418443..f64502d21a89 100644
  22. --- a/arch/x86/kvm/cpuid.c
  23. +++ b/arch/x86/kvm/cpuid.c
  24. @@ -70,6 +70,7 @@ u64 kvm_supported_xcr0(void)
  25. /* These are scattered features in cpufeatures.h. */
  26. #define KVM_CPUID_BIT_AVX512_4VNNIW 2
  27. #define KVM_CPUID_BIT_AVX512_4FMAPS 3
  28. +#define KVM_CPUID_BIT_SPEC_CTRL 26
  29. #define KF(x) bit(KVM_CPUID_BIT_##x)
  30. int kvm_update_cpuid(struct kvm_vcpu *vcpu)
  31. @@ -387,7 +388,12 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
  32. /* cpuid 7.0.edx*/
  33. const u32 kvm_cpuid_7_0_edx_x86_features =
  34. - KF(AVX512_4VNNIW) | KF(AVX512_4FMAPS);
  35. + KF(AVX512_4VNNIW) | KF(AVX512_4FMAPS) |
  36. + KF(SPEC_CTRL);
  37. +
  38. + /* cpuid 0x80000008.0.ebx */
  39. + const u32 kvm_cpuid_80000008_0_ebx_x86_features =
  40. + F(IBPB);
  41. /* all calls to cpuid_count() should be made on the same cpu */
  42. get_cpu();
  43. @@ -622,7 +628,9 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
  44. if (!g_phys_as)
  45. g_phys_as = phys_as;
  46. entry->eax = g_phys_as | (virt_as << 8);
  47. - entry->ebx = entry->edx = 0;
  48. + entry->ebx &= kvm_cpuid_80000008_0_ebx_x86_features;
  49. + cpuid_mask(&entry->ebx, CPUID_8000_0008_EBX);
  50. + entry->edx = 0;
  51. break;
  52. }
  53. case 0x80000019:
  54. --
  55. 2.14.2