diff mbox series

[1/2] intel-iommu: update root_scalable before switching as during post_load

Message ID 20220317080522.14621-1-jasowang@redhat.com (mailing list archive)
State New, archived
Headers show
Series [1/2] intel-iommu: update root_scalable before switching as during post_load | expand

Commit Message

Jason Wang March 17, 2022, 8:05 a.m. UTC
We need check whether passthrough is enabled during
vtd_switch_address_space() by checking the context entries. This
requires the root_scalable to be set correctly otherwise we may try to
check legacy rsvd bits instead of scalable ones.

Fixing this by updating root_scalable before switching the address
spaces during post_load.

Fixes: fb43cf739e ("intel_iommu: scalable mode emulation")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/i386/intel_iommu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Peter Xu March 18, 2022, 7:29 a.m. UTC | #1
On Thu, Mar 17, 2022 at 04:05:21PM +0800, Jason Wang wrote:
> We need check whether passthrough is enabled during
> vtd_switch_address_space() by checking the context entries. This
> requires the root_scalable to be set correctly otherwise we may try to
> check legacy rsvd bits instead of scalable ones.
> 
> Fixing this by updating root_scalable before switching the address
> spaces during post_load.
> 
> Fixes: fb43cf739e ("intel_iommu: scalable mode emulation")
> Signed-off-by: Jason Wang <jasowang@redhat.com>

Reviewed-by: Peter Xu <peterx@redhat.com>
diff mbox series

Patch

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 32471a44cb..a13cfecfce 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3052,13 +3052,6 @@  static int vtd_post_load(void *opaque, int version_id)
 {
     IntelIOMMUState *iommu = opaque;
 
-    /*
-     * Memory regions are dynamically turned on/off depending on
-     * context entry configurations from the guest. After migration,
-     * we need to make sure the memory regions are still correct.
-     */
-    vtd_switch_address_space_all(iommu);
-
     /*
      * We don't need to migrate the root_scalable because we can
      * simply do the calculation after the loading is complete.  We
@@ -3068,6 +3061,13 @@  static int vtd_post_load(void *opaque, int version_id)
      */
     vtd_update_scalable_state(iommu);
 
+    /*
+     * Memory regions are dynamically turned on/off depending on
+     * context entry configurations from the guest. After migration,
+     * we need to make sure the memory regions are still correct.
+     */
+    vtd_switch_address_space_all(iommu);
+
     return 0;
 }