~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/virt/kvm/locking.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/virt/kvm/locking.rst (Version linux-6.12-rc7) and /Documentation/virt/kvm/locking.rst (Version linux-6.9.12)


  1 .. SPDX-License-Identifier: GPL-2.0                 1 .. SPDX-License-Identifier: GPL-2.0
  2                                                     2 
  3 =================                                   3 =================
  4 KVM Lock Overview                                   4 KVM Lock Overview
  5 =================                                   5 =================
  6                                                     6 
  7 1. Acquisition Orders                               7 1. Acquisition Orders
  8 ---------------------                               8 ---------------------
  9                                                     9 
 10 The acquisition orders for mutexes are as foll     10 The acquisition orders for mutexes are as follows:
 11                                                    11 
 12 - cpus_read_lock() is taken outside kvm_lock       12 - cpus_read_lock() is taken outside kvm_lock
 13                                                    13 
 14 - kvm_usage_lock is taken outside cpus_read_lo << 
 15                                                << 
 16 - kvm->lock is taken outside vcpu->mutex           14 - kvm->lock is taken outside vcpu->mutex
 17                                                    15 
 18 - kvm->lock is taken outside kvm->slots_lock a     16 - kvm->lock is taken outside kvm->slots_lock and kvm->irq_lock
 19                                                    17 
 20 - kvm->slots_lock is taken outside kvm->irq_lo     18 - kvm->slots_lock is taken outside kvm->irq_lock, though acquiring
 21   them together is quite rare.                     19   them together is quite rare.
 22                                                    20 
 23 - kvm->mn_active_invalidate_count ensures that     21 - kvm->mn_active_invalidate_count ensures that pairs of
 24   invalidate_range_start() and invalidate_rang     22   invalidate_range_start() and invalidate_range_end() callbacks
 25   use the same memslots array.  kvm->slots_loc     23   use the same memslots array.  kvm->slots_lock and kvm->slots_arch_lock
 26   are taken on the waiting side when modifying     24   are taken on the waiting side when modifying memslots, so MMU notifiers
 27   must not take either kvm->slots_lock or kvm-     25   must not take either kvm->slots_lock or kvm->slots_arch_lock.
 28                                                    26 
 29 cpus_read_lock() vs kvm_lock:                  << 
 30                                                << 
 31 - Taking cpus_read_lock() outside of kvm_lock  << 
 32   being the official ordering, as it is quite  << 
 33   cpus_read_lock() while holding kvm_lock.  Us << 
 34   e.g. avoid complex operations when possible. << 
 35                                                << 
 36 For SRCU:                                          27 For SRCU:
 37                                                    28 
 38 - ``synchronize_srcu(&kvm->srcu)`` is called i     29 - ``synchronize_srcu(&kvm->srcu)`` is called inside critical sections
 39   for kvm->lock, vcpu->mutex and kvm->slots_lo     30   for kvm->lock, vcpu->mutex and kvm->slots_lock.  These locks _cannot_
 40   be taken inside a kvm->srcu read-side critic     31   be taken inside a kvm->srcu read-side critical section; that is, the
 41   following is broken::                            32   following is broken::
 42                                                    33 
 43       srcu_read_lock(&kvm->srcu);                  34       srcu_read_lock(&kvm->srcu);
 44       mutex_lock(&kvm->slots_lock);                35       mutex_lock(&kvm->slots_lock);
 45                                                    36 
 46 - kvm->slots_arch_lock instead is released bef     37 - kvm->slots_arch_lock instead is released before the call to
 47   ``synchronize_srcu()``.  It _can_ therefore      38   ``synchronize_srcu()``.  It _can_ therefore be taken inside a
 48   kvm->srcu read-side critical section, for ex     39   kvm->srcu read-side critical section, for example while processing
 49   a vmexit.                                        40   a vmexit.
 50                                                    41 
 51 On x86:                                            42 On x86:
 52                                                    43 
 53 - vcpu->mutex is taken outside kvm->arch.hyper     44 - vcpu->mutex is taken outside kvm->arch.hyperv.hv_lock and kvm->arch.xen.xen_lock
 54                                                    45 
 55 - kvm->arch.mmu_lock is an rwlock; critical se     46 - kvm->arch.mmu_lock is an rwlock; critical sections for
 56   kvm->arch.tdp_mmu_pages_lock and kvm->arch.m     47   kvm->arch.tdp_mmu_pages_lock and kvm->arch.mmu_unsync_pages_lock must
 57   also take kvm->arch.mmu_lock                     48   also take kvm->arch.mmu_lock
 58                                                    49 
 59 Everything else is a leaf: no other lock is ta     50 Everything else is a leaf: no other lock is taken inside the critical
 60 sections.                                          51 sections.
 61                                                    52 
 62 2. Exception                                       53 2. Exception
 63 ------------                                       54 ------------
 64                                                    55 
 65 Fast page fault:                                   56 Fast page fault:
 66                                                    57 
 67 Fast page fault is the fast path which fixes t     58 Fast page fault is the fast path which fixes the guest page fault out of
 68 the mmu-lock on x86. Currently, the page fault     59 the mmu-lock on x86. Currently, the page fault can be fast in one of the
 69 following two cases:                               60 following two cases:
 70                                                    61 
 71 1. Access Tracking: The SPTE is not present, b     62 1. Access Tracking: The SPTE is not present, but it is marked for access
 72    tracking. That means we need to restore the     63    tracking. That means we need to restore the saved R/X bits. This is
 73    described in more detail later below.           64    described in more detail later below.
 74                                                    65 
 75 2. Write-Protection: The SPTE is present and t     66 2. Write-Protection: The SPTE is present and the fault is caused by
 76    write-protect. That means we just need to c     67    write-protect. That means we just need to change the W bit of the spte.
 77                                                    68 
 78 What we use to avoid all the races is the Host     69 What we use to avoid all the races is the Host-writable bit and MMU-writable bit
 79 on the spte:                                       70 on the spte:
 80                                                    71 
 81 - Host-writable means the gfn is writable in t     72 - Host-writable means the gfn is writable in the host kernel page tables and in
 82   its KVM memslot.                                 73   its KVM memslot.
 83 - MMU-writable means the gfn is writable in th     74 - MMU-writable means the gfn is writable in the guest's mmu and it is not
 84   write-protected by shadow page write-protect     75   write-protected by shadow page write-protection.
 85                                                    76 
 86 On fast page fault path, we will use cmpxchg t     77 On fast page fault path, we will use cmpxchg to atomically set the spte W
 87 bit if spte.HOST_WRITEABLE = 1 and spte.WRITE_     78 bit if spte.HOST_WRITEABLE = 1 and spte.WRITE_PROTECT = 1, to restore the saved
 88 R/X bits if for an access-traced spte, or both     79 R/X bits if for an access-traced spte, or both. This is safe because whenever
 89 changing these bits can be detected by cmpxchg     80 changing these bits can be detected by cmpxchg.
 90                                                    81 
 91 But we need carefully check these cases:           82 But we need carefully check these cases:
 92                                                    83 
 93 1) The mapping from gfn to pfn                     84 1) The mapping from gfn to pfn
 94                                                    85 
 95 The mapping from gfn to pfn may be changed sin     86 The mapping from gfn to pfn may be changed since we can only ensure the pfn
 96 is not changed during cmpxchg. This is a ABA p     87 is not changed during cmpxchg. This is a ABA problem, for example, below case
 97 will happen:                                       88 will happen:
 98                                                    89 
 99 +---------------------------------------------     90 +------------------------------------------------------------------------+
100 | At the beginning::                               91 | At the beginning::                                                     |
101 |                                                  92 |                                                                        |
102 |       gpte = gfn1                                93 |       gpte = gfn1                                                      |
103 |       gfn1 is mapped to pfn1 on host             94 |       gfn1 is mapped to pfn1 on host                                   |
104 |       spte is the shadow page table entry co     95 |       spte is the shadow page table entry corresponding with gpte and  |
105 |       spte = pfn1                                96 |       spte = pfn1                                                      |
106 +---------------------------------------------     97 +------------------------------------------------------------------------+
107 | On fast page fault path:                         98 | On fast page fault path:                                               |
108 +------------------------------------+--------     99 +------------------------------------+-----------------------------------+
109 | CPU 0:                             | CPU 1:     100 | CPU 0:                             | CPU 1:                            |
110 +------------------------------------+--------    101 +------------------------------------+-----------------------------------+
111 | ::                                 |            102 | ::                                 |                                   |
112 |                                    |            103 |                                    |                                   |
113 |   old_spte = *spte;                |            104 |   old_spte = *spte;                |                                   |
114 +------------------------------------+--------    105 +------------------------------------+-----------------------------------+
115 |                                    | pfn1 is    106 |                                    | pfn1 is swapped out::             |
116 |                                    |            107 |                                    |                                   |
117 |                                    |    spte    108 |                                    |    spte = 0;                      |
118 |                                    |            109 |                                    |                                   |
119 |                                    | pfn1 is    110 |                                    | pfn1 is re-alloced for gfn2.      |
120 |                                    |            111 |                                    |                                   |
121 |                                    | gpte is    112 |                                    | gpte is changed to point to       |
122 |                                    | gfn2 by    113 |                                    | gfn2 by the guest::               |
123 |                                    |            114 |                                    |                                   |
124 |                                    |    spte    115 |                                    |    spte = pfn1;                   |
125 +------------------------------------+--------    116 +------------------------------------+-----------------------------------+
126 | ::                                              117 | ::                                                                     |
127 |                                                 118 |                                                                        |
128 |   if (cmpxchg(spte, old_spte, old_spte+W)       119 |   if (cmpxchg(spte, old_spte, old_spte+W)                              |
129 |       mark_page_dirty(vcpu->kvm, gfn1)          120 |       mark_page_dirty(vcpu->kvm, gfn1)                                 |
130 |            OOPS!!!                              121 |            OOPS!!!                                                     |
131 +---------------------------------------------    122 +------------------------------------------------------------------------+
132                                                   123 
133 We dirty-log for gfn1, that means gfn2 is lost    124 We dirty-log for gfn1, that means gfn2 is lost in dirty-bitmap.
134                                                   125 
135 For direct sp, we can easily avoid it since th    126 For direct sp, we can easily avoid it since the spte of direct sp is fixed
136 to gfn.  For indirect sp, we disabled fast pag    127 to gfn.  For indirect sp, we disabled fast page fault for simplicity.
137                                                   128 
138 A solution for indirect sp could be to pin the    129 A solution for indirect sp could be to pin the gfn, for example via
139 gfn_to_pfn_memslot_atomic, before the cmpxchg. !! 130 kvm_vcpu_gfn_to_pfn_atomic, before the cmpxchg.  After the pinning:
140                                                   131 
141 - We have held the refcount of pfn; that means    132 - We have held the refcount of pfn; that means the pfn can not be freed and
142   be reused for another gfn.                      133   be reused for another gfn.
143 - The pfn is writable and therefore it cannot     134 - The pfn is writable and therefore it cannot be shared between different gfns
144   by KSM.                                         135   by KSM.
145                                                   136 
146 Then, we can ensure the dirty bitmaps is corre    137 Then, we can ensure the dirty bitmaps is correctly set for a gfn.
147                                                   138 
148 2) Dirty bit tracking                             139 2) Dirty bit tracking
149                                                   140 
150 In the origin code, the spte can be fast updat    141 In the origin code, the spte can be fast updated (non-atomically) if the
151 spte is read-only and the Accessed bit has alr    142 spte is read-only and the Accessed bit has already been set since the
152 Accessed bit and Dirty bit can not be lost.       143 Accessed bit and Dirty bit can not be lost.
153                                                   144 
154 But it is not true after fast page fault since    145 But it is not true after fast page fault since the spte can be marked
155 writable between reading spte and updating spt    146 writable between reading spte and updating spte. Like below case:
156                                                   147 
157 +---------------------------------------------    148 +------------------------------------------------------------------------+
158 | At the beginning::                              149 | At the beginning::                                                     |
159 |                                                 150 |                                                                        |
160 |       spte.W = 0                                151 |       spte.W = 0                                                       |
161 |       spte.Accessed = 1                         152 |       spte.Accessed = 1                                                |
162 +------------------------------------+--------    153 +------------------------------------+-----------------------------------+
163 | CPU 0:                             | CPU 1:     154 | CPU 0:                             | CPU 1:                            |
164 +------------------------------------+--------    155 +------------------------------------+-----------------------------------+
165 | In mmu_spte_clear_track_bits()::   |            156 | In mmu_spte_clear_track_bits()::   |                                   |
166 |                                    |            157 |                                    |                                   |
167 |  old_spte = *spte;                 |            158 |  old_spte = *spte;                 |                                   |
168 |                                    |            159 |                                    |                                   |
169 |                                    |            160 |                                    |                                   |
170 |  /* 'if' condition is satisfied. */|            161 |  /* 'if' condition is satisfied. */|                                   |
171 |  if (old_spte.Accessed == 1 &&     |            162 |  if (old_spte.Accessed == 1 &&     |                                   |
172 |       old_spte.W == 0)             |            163 |       old_spte.W == 0)             |                                   |
173 |     spte = 0ull;                   |            164 |     spte = 0ull;                   |                                   |
174 +------------------------------------+--------    165 +------------------------------------+-----------------------------------+
175 |                                    | on fast    166 |                                    | on fast page fault path::         |
176 |                                    |            167 |                                    |                                   |
177 |                                    |    spte    168 |                                    |    spte.W = 1                     |
178 |                                    |            169 |                                    |                                   |
179 |                                    | memory     170 |                                    | memory write on the spte::        |
180 |                                    |            171 |                                    |                                   |
181 |                                    |    spte    172 |                                    |    spte.Dirty = 1                 |
182 +------------------------------------+--------    173 +------------------------------------+-----------------------------------+
183 |  ::                                |            174 |  ::                                |                                   |
184 |                                    |            175 |                                    |                                   |
185 |   else                             |            176 |   else                             |                                   |
186 |     old_spte = xchg(spte, 0ull)    |            177 |     old_spte = xchg(spte, 0ull)    |                                   |
187 |   if (old_spte.Accessed == 1)      |            178 |   if (old_spte.Accessed == 1)      |                                   |
188 |     kvm_set_pfn_accessed(spte.pfn);|            179 |     kvm_set_pfn_accessed(spte.pfn);|                                   |
189 |   if (old_spte.Dirty == 1)         |            180 |   if (old_spte.Dirty == 1)         |                                   |
190 |     kvm_set_pfn_dirty(spte.pfn);   |            181 |     kvm_set_pfn_dirty(spte.pfn);   |                                   |
191 |     OOPS!!!                        |            182 |     OOPS!!!                        |                                   |
192 +------------------------------------+--------    183 +------------------------------------+-----------------------------------+
193                                                   184 
194 The Dirty bit is lost in this case.               185 The Dirty bit is lost in this case.
195                                                   186 
196 In order to avoid this kind of issue, we alway    187 In order to avoid this kind of issue, we always treat the spte as "volatile"
197 if it can be updated out of mmu-lock [see spte    188 if it can be updated out of mmu-lock [see spte_has_volatile_bits()]; it means
198 the spte is always atomically updated in this     189 the spte is always atomically updated in this case.
199                                                   190 
200 3) flush tlbs due to spte updated                 191 3) flush tlbs due to spte updated
201                                                   192 
202 If the spte is updated from writable to read-o    193 If the spte is updated from writable to read-only, we should flush all TLBs,
203 otherwise rmap_write_protect will find a read-    194 otherwise rmap_write_protect will find a read-only spte, even though the
204 writable spte might be cached on a CPU's TLB.     195 writable spte might be cached on a CPU's TLB.
205                                                   196 
206 As mentioned before, the spte can be updated t    197 As mentioned before, the spte can be updated to writable out of mmu-lock on
207 fast page fault path. In order to easily audit    198 fast page fault path. In order to easily audit the path, we see if TLBs needing
208 to be flushed caused this reason in mmu_spte_u    199 to be flushed caused this reason in mmu_spte_update() since this is a common
209 function to update spte (present -> present).     200 function to update spte (present -> present).
210                                                   201 
211 Since the spte is "volatile" if it can be upda    202 Since the spte is "volatile" if it can be updated out of mmu-lock, we always
212 atomically update the spte and the race caused    203 atomically update the spte and the race caused by fast page fault can be avoided.
213 See the comments in spte_has_volatile_bits() a    204 See the comments in spte_has_volatile_bits() and mmu_spte_update().
214                                                   205 
215 Lockless Access Tracking:                         206 Lockless Access Tracking:
216                                                   207 
217 This is used for Intel CPUs that are using EPT    208 This is used for Intel CPUs that are using EPT but do not support the EPT A/D
218 bits. In this case, PTEs are tagged as A/D dis    209 bits. In this case, PTEs are tagged as A/D disabled (using ignored bits), and
219 when the KVM MMU notifier is called to track a    210 when the KVM MMU notifier is called to track accesses to a page (via
220 kvm_mmu_notifier_clear_flush_young), it marks     211 kvm_mmu_notifier_clear_flush_young), it marks the PTE not-present in hardware
221 by clearing the RWX bits in the PTE and storin    212 by clearing the RWX bits in the PTE and storing the original R & X bits in more
222 unused/ignored bits. When the VM tries to acce    213 unused/ignored bits. When the VM tries to access the page later on, a fault is
223 generated and the fast page fault mechanism de    214 generated and the fast page fault mechanism described above is used to
224 atomically restore the PTE to a Present state.    215 atomically restore the PTE to a Present state. The W bit is not saved when the
225 PTE is marked for access tracking and during r    216 PTE is marked for access tracking and during restoration to the Present state,
226 the W bit is set depending on whether or not i    217 the W bit is set depending on whether or not it was a write access. If it
227 wasn't, then the W bit will remain clear until    218 wasn't, then the W bit will remain clear until a write access happens, at which
228 time it will be set using the Dirty tracking m    219 time it will be set using the Dirty tracking mechanism described above.
229                                                   220 
230 3. Reference                                      221 3. Reference
231 ------------                                      222 ------------
232                                                   223 
233 ``kvm_lock``                                      224 ``kvm_lock``
234 ^^^^^^^^^^^^                                      225 ^^^^^^^^^^^^
235                                                   226 
236 :Type:          mutex                             227 :Type:          mutex
237 :Arch:          any                               228 :Arch:          any
238 :Protects:      - vm_list                         229 :Protects:      - vm_list
239                                                !! 230                 - kvm_usage_count
240 ``kvm_usage_lock``                             << 
241 ^^^^^^^^^^^^^^^^^^                             << 
242                                                << 
243 :Type:          mutex                          << 
244 :Arch:          any                            << 
245 :Protects:      - kvm_usage_count              << 
246                 - hardware virtualization enab    231                 - hardware virtualization enable/disable
247 :Comment:       Exists to allow taking cpus_re !! 232 :Comment:       KVM also disables CPU hotplug via cpus_read_lock() during
248                 protected, which simplifies th !! 233                 enable/disable.
249                                                   234 
250 ``kvm->mn_invalidate_lock``                       235 ``kvm->mn_invalidate_lock``
251 ^^^^^^^^^^^^^^^^^^^^^^^^^^^                       236 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
252                                                   237 
253 :Type:          spinlock_t                        238 :Type:          spinlock_t
254 :Arch:          any                               239 :Arch:          any
255 :Protects:      mn_active_invalidate_count, mn    240 :Protects:      mn_active_invalidate_count, mn_memslots_update_rcuwait
256                                                   241 
257 ``kvm_arch::tsc_write_lock``                      242 ``kvm_arch::tsc_write_lock``
258 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^                      243 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
259                                                   244 
260 :Type:          raw_spinlock_t                    245 :Type:          raw_spinlock_t
261 :Arch:          x86                               246 :Arch:          x86
262 :Protects:      - kvm_arch::{last_tsc_write,la    247 :Protects:      - kvm_arch::{last_tsc_write,last_tsc_nsec,last_tsc_offset}
263                 - tsc offset in vmcb              248                 - tsc offset in vmcb
264 :Comment:       'raw' because updating the tsc    249 :Comment:       'raw' because updating the tsc offsets must not be preempted.
265                                                   250 
266 ``kvm->mmu_lock``                                 251 ``kvm->mmu_lock``
267 ^^^^^^^^^^^^^^^^^                                 252 ^^^^^^^^^^^^^^^^^
268 :Type:          spinlock_t or rwlock_t            253 :Type:          spinlock_t or rwlock_t
269 :Arch:          any                               254 :Arch:          any
270 :Protects:      -shadow page/shadow tlb entry     255 :Protects:      -shadow page/shadow tlb entry
271 :Comment:       it is a spinlock since it is u    256 :Comment:       it is a spinlock since it is used in mmu notifier.
272                                                   257 
273 ``kvm->srcu``                                     258 ``kvm->srcu``
274 ^^^^^^^^^^^^^                                     259 ^^^^^^^^^^^^^
275 :Type:          srcu lock                         260 :Type:          srcu lock
276 :Arch:          any                               261 :Arch:          any
277 :Protects:      - kvm->memslots                   262 :Protects:      - kvm->memslots
278                 - kvm->buses                      263                 - kvm->buses
279 :Comment:       The srcu read lock must be hel    264 :Comment:       The srcu read lock must be held while accessing memslots (e.g.
280                 when using gfn_to_* functions)    265                 when using gfn_to_* functions) and while accessing in-kernel
281                 MMIO/PIO address->device struc    266                 MMIO/PIO address->device structure mapping (kvm->buses).
282                 The srcu index can be stored i    267                 The srcu index can be stored in kvm_vcpu->srcu_idx per vcpu
283                 if it is needed by multiple fu    268                 if it is needed by multiple functions.
284                                                   269 
285 ``kvm->slots_arch_lock``                          270 ``kvm->slots_arch_lock``
286 ^^^^^^^^^^^^^^^^^^^^^^^^                          271 ^^^^^^^^^^^^^^^^^^^^^^^^
287 :Type:          mutex                             272 :Type:          mutex
288 :Arch:          any (only needed on x86 though    273 :Arch:          any (only needed on x86 though)
289 :Protects:      any arch-specific fields of me    274 :Protects:      any arch-specific fields of memslots that have to be modified
290                 in a ``kvm->srcu`` read-side c    275                 in a ``kvm->srcu`` read-side critical section.
291 :Comment:       must be held before reading th    276 :Comment:       must be held before reading the pointer to the current memslots,
292                 until after all changes to the    277                 until after all changes to the memslots are complete
293                                                   278 
294 ``wakeup_vcpus_on_cpu_lock``                      279 ``wakeup_vcpus_on_cpu_lock``
295 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^                      280 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
296 :Type:          spinlock_t                        281 :Type:          spinlock_t
297 :Arch:          x86                               282 :Arch:          x86
298 :Protects:      wakeup_vcpus_on_cpu               283 :Protects:      wakeup_vcpus_on_cpu
299 :Comment:       This is a per-CPU lock and it     284 :Comment:       This is a per-CPU lock and it is used for VT-d posted-interrupts.
300                 When VT-d posted-interrupts ar    285                 When VT-d posted-interrupts are supported and the VM has assigned
301                 devices, we put the blocked vC    286                 devices, we put the blocked vCPU on the list blocked_vcpu_on_cpu
302                 protected by blocked_vcpu_on_c    287                 protected by blocked_vcpu_on_cpu_lock. When VT-d hardware issues
303                 wakeup notification event sinc    288                 wakeup notification event since external interrupts from the
304                 assigned devices happens, we w    289                 assigned devices happens, we will find the vCPU on the list to
305                 wakeup.                           290                 wakeup.
306                                                   291 
307 ``vendor_module_lock``                            292 ``vendor_module_lock``
308 ^^^^^^^^^^^^^^^^^^^^^^                         !! 293 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
309 :Type:          mutex                             294 :Type:          mutex
310 :Arch:          x86                               295 :Arch:          x86
311 :Protects:      loading a vendor module (kvm_a    296 :Protects:      loading a vendor module (kvm_amd or kvm_intel)
312 :Comment:       Exists because using kvm_lock  !! 297 :Comment:       Exists because using kvm_lock leads to deadlock.  cpu_hotplug_lock is
313     in notifiers, e.g. __kvmclock_cpufreq_noti !! 298     taken outside of kvm_lock, e.g. in KVM's CPU online/offline callbacks, and
314     cpu_hotplug_lock is held, e.g. from cpufre !! 299     many operations need to take cpu_hotplug_lock when loading a vendor module,
315     operations need to take cpu_hotplug_lock w !! 300     e.g. updating static calls.
316     updating static calls.                     << 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php