summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Jimenez <alejandro.j.jimenez@oracle.com>2026-03-30 21:28:17 +0000
committerMichael Tokarev <mjt@tls.msk.ru>2026-06-16 19:16:26 +0300
commit15e63b7baf011f154bab0d52f33d3876fa7b97a8 (patch)
tree541a6d356528084989d1d8651bcac55eb0c13e01
parentad734bea5f679a2f732360852249bbad879a16b7 (diff)
downloadqemu-15e63b7baf011f154bab0d52f33d3876fa7b97a8.tar.gz
qemu-15e63b7baf011f154bab0d52f33d3876fa7b97a8.zip
amd_iommu: Reject non-decreasing NextLevel in fetch_pte()
The AMD-Vi specification requires that the NextLevel field for a page table entry must not be greater or equal to the current page table entry level. Enforce this to avoid infinite page walk loops on corrupted or buggy guest page tables. The initial implementation of fetch_pte() did not implement this check, but was not vulnerable since the page walk code explicitly decremented the level instead of retrieving it from the page table entry. Cc: qemu-stable@nongnu.org Reviewed-by: Sairaj Kodilkar <sarunkod@amd.com> Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260330212817.992673-3-alejandro.j.jimenez@oracle.com> (cherry picked from commit 291aa70ad254b6c48012dbfd16a4af0978ea1b84) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--hw/i386/amd_iommu.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 86dab42624..a7991b2790 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -771,6 +771,10 @@ static uint64_t fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint64_t dte,
break;
}
+ /* Next level must always be less than current level */
+ if (pt_level <= next_pt_level) {
+ return -AMDVI_FR_PT_ENTRY_INV;
+ }
pt_level = next_pt_level;
/*