Skip to content

Commit 9be15fb

Browse files
ashkalrajoergroedel
authored andcommitted
iommu/amd: Skip enabling command/event buffers for kdump
After a panic if SNP is enabled in the previous kernel then the kdump kernel boots with IOMMU SNP enforcement still enabled. IOMMU command buffers and event buffer registers remain locked and exclusive to the previous kernel. Attempts to enable command and event buffers in the kdump kernel will fail, as hardware ignores writes to the locked MMIO registers as per AMD IOMMU spec Section 2.12.2.1. Skip enabling command buffers and event buffers for kdump boot as they are already enabled in the previous kernel. Reviewed-by: Vasant Hegde <[email protected]> Tested-by: Sairaj Kodilkar <[email protected]> Signed-off-by: Ashish Kalra <[email protected]> Link: https://lore.kernel.org/r/576445eb4f168b467b0fc789079b650ca7c5b037.1756157913.git.ashish.kalra@amd.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 8c57101 commit 9be15fb

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

drivers/iommu/amd/init.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -821,11 +821,16 @@ static void iommu_enable_command_buffer(struct amd_iommu *iommu)
821821

822822
BUG_ON(iommu->cmd_buf == NULL);
823823

824-
entry = iommu_virt_to_phys(iommu->cmd_buf);
825-
entry |= MMIO_CMD_SIZE_512;
826-
827-
memcpy_toio(iommu->mmio_base + MMIO_CMD_BUF_OFFSET,
828-
&entry, sizeof(entry));
824+
if (!is_kdump_kernel()) {
825+
/*
826+
* Command buffer is re-used for kdump kernel and setting
827+
* of MMIO register is not required.
828+
*/
829+
entry = iommu_virt_to_phys(iommu->cmd_buf);
830+
entry |= MMIO_CMD_SIZE_512;
831+
memcpy_toio(iommu->mmio_base + MMIO_CMD_BUF_OFFSET,
832+
&entry, sizeof(entry));
833+
}
829834

830835
amd_iommu_reset_cmd_buffer(iommu);
831836
}
@@ -876,10 +881,15 @@ static void iommu_enable_event_buffer(struct amd_iommu *iommu)
876881

877882
BUG_ON(iommu->evt_buf == NULL);
878883

879-
entry = iommu_virt_to_phys(iommu->evt_buf) | EVT_LEN_MASK;
880-
881-
memcpy_toio(iommu->mmio_base + MMIO_EVT_BUF_OFFSET,
882-
&entry, sizeof(entry));
884+
if (!is_kdump_kernel()) {
885+
/*
886+
* Event buffer is re-used for kdump kernel and setting
887+
* of MMIO register is not required.
888+
*/
889+
entry = iommu_virt_to_phys(iommu->evt_buf) | EVT_LEN_MASK;
890+
memcpy_toio(iommu->mmio_base + MMIO_EVT_BUF_OFFSET,
891+
&entry, sizeof(entry));
892+
}
883893

884894
/* set head and tail to zero manually */
885895
writel(0x00, iommu->mmio_base + MMIO_EVT_HEAD_OFFSET);

0 commit comments

Comments
 (0)