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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Tue, 13 May 2025 11:44:19 -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=enXK7WDmRHrwdQGLUmkJKQ17xE1Qn3TxOFzOTixdoVc=; b=ZYZ7qEfQUyRmkHwCLCtWl5DZw4Ru2fFG/lWfRnTs89Ov4aCxxaWINaIYfmHAWN0rv3VMasOkVEVxrNNpgPDzWtRNWLK9nMutzd5WL9XpyKd9Eu4klO57u5TQ3tK/eiu/GSmsBvsZUuhvgYtFRzGDfZeHXCipJPUbsDvlPQlmpUwNnoCiNvQSjQ4+cINozhf9n8ZQUukne+f+cUydRHPlhMlDLX7NnXBo2NEh+hpqVew9RbpNueScHhiKlTZjl9lW8/iypObtgIVU/PChMl2/U/N3eRlphsfNGHuo3JoghiFmS/wZqWAd8iW3zvvO09752zpS3sZ3H8BzauDez81qQQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NvNqk7c5V3W9kX40lc+e7i0qVLuX9U/fumAF1DPsVFHmg8f1WzYiYX3BDxU38S1H/tDFg8fmhD3bdulErXL4XRP3vNCNvUYkhCXx9GSfGXU/NOrEVn+RawjfCigUBXWUin+uazCiSKrWVDTE1HdQrURQ24mt0U+IcqR7E4Lw/B3jCcoxCSTajLjSRqC6/I4JA9oxe13dW2JVhqYPb5sqjTSdOJuJ1qtNHVcXPh+Mw/xydWWB6yo6H+BIT8CcdjrWdNWpvYsaVH/Nmzr9gz9LJkJGZUgSo5jeWkaOxtjclLM9LpaIhvlhe+pDW3dDl0NTNWajoc/SmhgH32uFQPwwdw==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Tue, 13 May 2025 15:44:55 +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 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>
---
v2:
Move comment.
---
 tools/libs/light/libxl_x86.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c
index 0b1c2d3a96..867addfcab 100644
--- a/tools/libs/light/libxl_x86.c
+++ b/tools/libs/light/libxl_x86.c
@@ -814,17 +814,19 @@ int libxl__arch_domain_build_info_setdefault(libxl__gc 
*gc,
     libxl_defbool_setdefault(&b_info->acpi, true);
     libxl_defbool_setdefault(&b_info->arch_x86.msr_relaxed, false);
 
-    /*
-     * The config parameter "altp2m" replaces the parameter "altp2mhvm".
-     * For legacy reasons, both parameters are accepted on x86 HVM guests.
-     *
-     * 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) {
+        /*
+         * The config parameter "altp2m" replaces the parameter "altp2mhvm".
+         * For legacy reasons, both parameters are accepted on x86 HVM guests.
+         *
+         * 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);
+    }
 
     return 0;
 }
-- 
2.49.0




 


Rackspace

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