Commit a889ea5
KVM: x86/mmu: Ensure TDP MMU roots are freed after yield
Many TDP MMU functions which need to perform some action on all TDP MMU
roots hold a reference on that root so that they can safely drop the MMU
lock in order to yield to other threads. However, when releasing the
reference on the root, there is a bug: the root will not be freed even
if its reference count (root_count) is reduced to 0.
To simplify acquiring and releasing references on TDP MMU root pages, and
to ensure that these roots are properly freed, move the get/put operations
into another TDP MMU root iterator macro.
Moving the get/put operations into an iterator macro also helps
simplify control flow when a root does need to be freed. Note that using
the list_for_each_entry_safe macro would not have been appropriate in
this situation because it could keep a pointer to the next root across
an MMU lock release + reacquire, during which time that root could be
freed.
Reported-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Fixes: faaf05b ("kvm: x86/mmu: Support zapping SPTEs in the TDP MMU")
Fixes: 063afac ("kvm: x86/mmu: Support invalidate range MMU notifier for TDP MMU")
Fixes: a6a0b05 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
Fixes: 1488199 ("kvm: x86/mmu: Support disabling dirty logging for the tdp MMU")
Signed-off-by: Ben Gardon <bgardon@google.com>
Message-Id: <20210107001935.3732070-1-bgardon@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>1 parent 88bf56d commit a889ea5
1 file changed
+48
-56
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
48 | 89 | | |
49 | 90 | | |
50 | 91 | | |
| |||
447 | 488 | | |
448 | 489 | | |
449 | 490 | | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 491 | + | |
457 | 492 | | |
458 | 493 | | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | 494 | | |
463 | 495 | | |
464 | 496 | | |
| |||
619 | 651 | | |
620 | 652 | | |
621 | 653 | | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
| 654 | + | |
629 | 655 | | |
630 | 656 | | |
631 | 657 | | |
| |||
647 | 673 | | |
648 | 674 | | |
649 | 675 | | |
650 | | - | |
651 | | - | |
652 | 676 | | |
653 | 677 | | |
654 | 678 | | |
| |||
838 | 862 | | |
839 | 863 | | |
840 | 864 | | |
841 | | - | |
| 865 | + | |
842 | 866 | | |
843 | 867 | | |
844 | 868 | | |
845 | 869 | | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | 870 | | |
853 | 871 | | |
854 | | - | |
855 | | - | |
856 | 872 | | |
857 | 873 | | |
858 | 874 | | |
| |||
906 | 922 | | |
907 | 923 | | |
908 | 924 | | |
909 | | - | |
| 925 | + | |
910 | 926 | | |
911 | 927 | | |
912 | 928 | | |
913 | 929 | | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | 930 | | |
921 | 931 | | |
922 | | - | |
923 | | - | |
924 | 932 | | |
925 | 933 | | |
926 | 934 | | |
| |||
1029 | 1037 | | |
1030 | 1038 | | |
1031 | 1039 | | |
1032 | | - | |
| 1040 | + | |
1033 | 1041 | | |
1034 | 1042 | | |
1035 | 1043 | | |
1036 | 1044 | | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | 1045 | | |
1044 | 1046 | | |
1045 | | - | |
1046 | | - | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | 1049 | | |
| |||
1089 | 1089 | | |
1090 | 1090 | | |
1091 | 1091 | | |
1092 | | - | |
| 1092 | + | |
1093 | 1093 | | |
1094 | 1094 | | |
1095 | 1095 | | |
1096 | 1096 | | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | 1097 | | |
1104 | 1098 | | |
1105 | | - | |
1106 | | - | |
1107 | 1099 | | |
1108 | 1100 | | |
1109 | 1101 | | |
| |||
0 commit comments