[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tools/libxl: Only access legacy altp2m on HVM


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Mon, 12 May 2025 19:54:07 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aF6YROwOuGlvpozS/KCefgc2H3PvRpkN/JGW+4Y0CPA=; b=xU1xSWwx7ZVIohcRScwyuqPyAUI4B4/GKCfyQ4Lhpj3Ef2lbC6xZTRWq7rogajTmaElu++RQHAxamFg+BZUY76cJKd136ydzVctRCb535MV4YPa8inTBQ8yv5bUfxen9kouQ6KTc5TQUXnDNsWHuZ+a6CKBXshqJZ1TnoM1cdo/3PbIB5A15ETBnpk8EirH22ompcajAnWv7r/SVtvYIDI4JRCxbSiMT1JKwCC+p1Y8KTRkwooKAJ0e3K7Rhv+kMibOa/tafx6m8/AUe/fFimNd4V4NoiNGbuhLL7VVmwJzh13uOBxzjiYtmwWVTtpWwfmEgnNioA4+7XQTiu2S4tw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N3kzDHPIpEf5EevnDgjJoEcaI7xJ4C3ubiE8ViyT1eA2PBSt2peEzGa/cR5yd0pgIiz1SspbJR5fIMjk/Gp6xmIHy0iQDkM/Hf6+t8TmNk/262PQZFGaFdMBF5MITADqKpDpcIAz/GKNzo/rl0czspY1NV8V4YIX3aQgrT2AbIw2ziB7jTzq1w5LxSP7vDfAnG1zoYhslbB01gxN5gy+Co9gmB0Z7LV3ugdtDPnE3pxQp2dhs7+J01kQoDKa6kbwmUpXf3kINubNwRX1/WgEc8GeayZpZGXtz6E96HCOBWd3UMS5Fg677WwNVRVLJ6CWzmwWsl199gEBZale8AbYjA==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Mon, 12 May 2025 23:54:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Only access the HVM union b_info->u.hvm on HVM guests.  The union
access is not guarded, so this reads and sets the default even on
non-HVM guests.  Usually this doesn't matter as PV and PVH unions are
smaller and zero-initialized, but the zero default will be re-written as
a -1 boolean.  Generally, it it could incorrectly set b_info->altp2m
through aliased data.

Fixes: 0291089f6ea8 ("xen: enable altp2m at create domain domctl")
Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
Change-Id: Ifaca3533dcce3f409c2efa292c7e96fba6371d9d
---
 tools/libs/light/libxl_x86.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c
index 0b1c2d3a96..b8f6663829 100644
--- a/tools/libs/light/libxl_x86.c
+++ b/tools/libs/light/libxl_x86.c
@@ -821,10 +821,12 @@ int libxl__arch_domain_build_info_setdefault(libxl__gc 
*gc,
      * If the legacy field info->u.hvm.altp2m is set, activate altp2m.
      * Otherwise set altp2m based on the field info->altp2m.
      */
-    libxl_defbool_setdefault(&b_info->u.hvm.altp2m, false);
-    if (b_info->altp2m == LIBXL_ALTP2M_MODE_DISABLED &&
-        libxl_defbool_val(b_info->u.hvm.altp2m))
-        b_info->altp2m = libxl_defbool_val(b_info->u.hvm.altp2m);
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
+        libxl_defbool_setdefault(&b_info->u.hvm.altp2m, false);
+        if (b_info->altp2m == LIBXL_ALTP2M_MODE_DISABLED &&
+            libxl_defbool_val(b_info->u.hvm.altp2m))
+            b_info->altp2m = libxl_defbool_val(b_info->u.hvm.altp2m);
+    }
 
     return 0;
 }
-- 
2.49.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.