Commit 4c08e73
committed
KVM: SVM: Take and hold ir_list_lock when updating vCPU's Physical ID entry
Hoist the acquisition of ir_list_lock from avic_update_iommu_vcpu_affinity()
to its two callers, avic_vcpu_load() and avic_vcpu_put(), specifically to
encapsulate the write to the vCPU's entry in the AVIC Physical ID table.
This will allow a future fix to pull information from the Physical ID entry
when updating the IRTE, without potentially consuming stale information,
i.e. without racing with the vCPU being (un)loaded.
Add a comment to call out that ir_list_lock does NOT protect against
multiple writers, specifically that reading the Physical ID entry in
avic_vcpu_put() outside of the lock is safe.
To preserve some semblance of independence from ir_list_lock, keep the
READ_ONCE() in avic_vcpu_load() even though acuiring the spinlock
effectively ensures the load(s) will be generated after acquiring the
lock.
Cc: stable@vger.kernel.org
Tested-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Link: https://lore.kernel.org/r/20230808233132.2499764-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent a85cd52 commit 4c08e73
1 file changed
Lines changed: 23 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
986 | 986 | | |
987 | 987 | | |
988 | 988 | | |
989 | | - | |
990 | 989 | | |
991 | 990 | | |
992 | 991 | | |
| 992 | + | |
| 993 | + | |
993 | 994 | | |
994 | 995 | | |
995 | 996 | | |
996 | 997 | | |
997 | 998 | | |
998 | 999 | | |
999 | 1000 | | |
1000 | | - | |
1001 | | - | |
1002 | 1001 | | |
1003 | | - | |
| 1002 | + | |
1004 | 1003 | | |
1005 | 1004 | | |
1006 | 1005 | | |
1007 | 1006 | | |
1008 | | - | |
| 1007 | + | |
1009 | 1008 | | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
| 1009 | + | |
1013 | 1010 | | |
1014 | 1011 | | |
1015 | 1012 | | |
1016 | 1013 | | |
1017 | 1014 | | |
1018 | 1015 | | |
1019 | 1016 | | |
| 1017 | + | |
1020 | 1018 | | |
1021 | 1019 | | |
1022 | 1020 | | |
| |||
1033 | 1031 | | |
1034 | 1032 | | |
1035 | 1033 | | |
| 1034 | + | |
| 1035 | + | |
1036 | 1036 | | |
1037 | 1037 | | |
1038 | 1038 | | |
| |||
1042 | 1042 | | |
1043 | 1043 | | |
1044 | 1044 | | |
| 1045 | + | |
| 1046 | + | |
1045 | 1047 | | |
1046 | 1048 | | |
1047 | 1049 | | |
1048 | 1050 | | |
1049 | 1051 | | |
1050 | 1052 | | |
| 1053 | + | |
1051 | 1054 | | |
1052 | 1055 | | |
1053 | 1056 | | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1054 | 1064 | | |
1055 | 1065 | | |
1056 | 1066 | | |
1057 | 1067 | | |
1058 | 1068 | | |
1059 | 1069 | | |
| 1070 | + | |
| 1071 | + | |
1060 | 1072 | | |
1061 | 1073 | | |
1062 | 1074 | | |
1063 | 1075 | | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
1064 | 1079 | | |
1065 | 1080 | | |
1066 | 1081 | | |
| |||
0 commit comments