0011-x86-KVM-Clean-up-host-s-steal-time-structure.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Boris Ostrovsky <[email protected]>
  3. Date: Fri, 31 Jan 2020 08:06:44 -0300
  4. Subject: [PATCH] x86/KVM: Clean up host's steal time structure
  5. CVE-2019-3016
  6. CVE-2020-3016
  7. Now that we are mapping kvm_steal_time from the guest directly we
  8. don't need keep a copy of it in kvm_vcpu_arch.st. The same is true
  9. for the stime field.
  10. This is part of CVE-2019-3016.
  11. Signed-off-by: Boris Ostrovsky <[email protected]>
  12. Reviewed-by: Joao Martins <[email protected]>
  13. Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]>
  14. Signed-off-by: Thomas Lamprecht <[email protected]>
  15. ---
  16. arch/x86/include/asm/kvm_host.h | 3 +--
  17. arch/x86/kvm/x86.c | 11 +++--------
  18. 2 files changed, 4 insertions(+), 10 deletions(-)
  19. diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
  20. index 7c06343614a4..f62f4ff5f4f4 100644
  21. --- a/arch/x86/include/asm/kvm_host.h
  22. +++ b/arch/x86/include/asm/kvm_host.h
  23. @@ -674,10 +674,9 @@ struct kvm_vcpu_arch {
  24. bool pvclock_set_guest_stopped_request;
  25. struct {
  26. + u8 preempted;
  27. u64 msr_val;
  28. u64 last_steal;
  29. - struct gfn_to_hva_cache stime;
  30. - struct kvm_steal_time steal;
  31. struct gfn_to_pfn_cache cache;
  32. } st;
  33. diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
  34. index f63fa5846f08..6ce9ace8a801 100644
  35. --- a/arch/x86/kvm/x86.c
  36. +++ b/arch/x86/kvm/x86.c
  37. @@ -2509,7 +2509,7 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
  38. if (xchg(&st->preempted, 0) & KVM_VCPU_FLUSH_TLB)
  39. kvm_vcpu_flush_tlb(vcpu, false);
  40. - vcpu->arch.st.steal.preempted = 0;
  41. + vcpu->arch.st.preempted = 0;
  42. if (st->version & 1)
  43. st->version += 1; /* first time write, random junk */
  44. @@ -2682,11 +2682,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
  45. if (data & KVM_STEAL_RESERVED_MASK)
  46. return 1;
  47. - if (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.st.stime,
  48. - data & KVM_STEAL_VALID_BITS,
  49. - sizeof(struct kvm_steal_time)))
  50. - return 1;
  51. -
  52. vcpu->arch.st.msr_val = data;
  53. if (!(data & KVM_MSR_ENABLED))
  54. @@ -3404,7 +3399,7 @@ static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu)
  55. if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED))
  56. return;
  57. - if (vcpu->arch.st.steal.preempted)
  58. + if (vcpu->arch.st.preempted)
  59. return;
  60. if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT, &map,
  61. @@ -3414,7 +3409,7 @@ static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu)
  62. st = map.hva +
  63. offset_in_page(vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS);
  64. - st->preempted = vcpu->arch.st.steal.preempted = KVM_VCPU_PREEMPTED;
  65. + st->preempted = vcpu->arch.st.preempted = KVM_VCPU_PREEMPTED;
  66. kvm_unmap_gfn(vcpu, &map, &vcpu->arch.st.cache, true, true);
  67. }