iommu/amd: Continue the completion sequence in SNP kdump
Subsystems (2)
Vasant Hegde
maintainerPATCH 1/1 iommu/amd: Continue the completion sequence in SNP kdump
SNP kdump remaps the previous kernel's completion-wait semaphore because the completion-store registers are locked. That page already holds the last sequence number the IOMMU stored, but cmd_sem_val starts at zero.
wait_on_sem() returns once the stored value is at least the target. Until the new counter catches up, every completion wait succeeds before the IOMMU has executed the command. That includes the cache flushes issued while the kdump kernel adopts the old device table.
When the old device table is reused, sample the semaphore after the command buffer is disabled. A completion wait fetched before that can still store a later sequence number. The old command buffer holds at most 512 commands, so continue that far past the sampled value.
--- drivers/iommu/amd/init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/iommu/amd/init.c +14 -0
@@ -2992,6 +2992,20 @@ static void early_enable_iommus(void)for_each_iommu (iommu) {iommu_disable_command_buffer (iommu); + +/* +* SNP reuses the previous kernel's completion +* semaphore. wait_on_sem() returns once the stored +* value is at least the target. A completion wait +* fetched before CmdBufEn was cleared can still +* store a later value, and the old command buffer +* holds at most CMD_BUFFER_ENTRIES such commands. +* Continue past that range. A new page reads as +* zero, so this only skips those entries. +*/ + iommu->cmd_sem_val =READ_ONCE (*iommu->cmd_sem) + +CMD_BUFFER_ENTRIES ; +iommu_disable_event_buffer (iommu);iommu_disable_irtcachedis (iommu);iommu_enable_command_buffer (iommu);
Signature · 1 line
2.31.1