[RFC PATCH 03/15] iommu/vt-d: Prevent hotplugs when live update state is not normal

Samiullah Khawaja
2025-09-28T19:07:46Z

Hotplugs should not be allowed when the live update state is not normal.
This means either we have preserved the state of IOMMU hardware units or
restoring the preserved state.

The live update semaphore read lock should be taken before checking the
live update state.

Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
---
drivers/iommu/intel/dmar.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index ec975c73cfe6..248bc7e9b035 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -26,6 +26,7 @@
#include <linux/dmi.h>
#include <linux/slab.h>
#include <linux/iommu.h>
+#include <linux/liveupdate.h>
#include <linux/numa.h>
#include <linux/limits.h>
#include <asm/irq_remapping.h>
@@ -2357,6 +2358,10 @@ static int dmar_device_hotplug(acpi_handle handle, bool insert)
if (tmp == NULL)
return 0;

+ guard_liveupdate_state_read();
+ if (!liveupdate_state_normal())
+ return -EBUSY;
+
down_write(&dmar_global_lock);
if (insert)
ret = dmar_hotplug_insert(tmp);
--
2.51.0.536.g15c5d4f767-goog