From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696981; cv=none; d=zohomail.com; s=zohoarc; b=SzVQE2DgWGEn+ENqnf74rsw3T3o1x2yVbPJ366yiHyJYvSDfiobqSWp0qhiztetr4uYlbSWp/CBtpMEUdCKnXhqvkDYmO1HNTzARKggG+dd135Ig/cmlrr/iQ0thnsD4wDJ4sO+oVz3QjHopIsxLwrM1v6ebuyr70KJwW3s+CPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696981; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wDovwYR+MAaNPWm/pgK0ijg6p2MZFtuj4DNgoEH65mE=; b=iDQseGEBS4ZJmHymJvmW9rGzBzkb+1ay4Tt5aICf1VF0Hb0MzfI3zHfslXmH410wKz4K70eX6bVYBKiHzMve+bvdXvHSn9s2nZx2yX6WLT/Y23ZdTf0ggMbAS5AbF9l+BzbeelgJPXjJqxxzieDS8hPrClcKg8lbuLfiV6Pc8uA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1752696981668224.54058101484497; Wed, 16 Jul 2025 13:16:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045625.1415776 (Exim 4.92) (envelope-from ) id 1uc8Xl-00043O-4R; Wed, 16 Jul 2025 20:15:57 +0000 Received: by outflank-mailman (output) from mailman id 1045625.1415776; Wed, 16 Jul 2025 20:15:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xk-00040H-TZ; Wed, 16 Jul 2025 20:15:56 +0000 Received: by outflank-mailman (input) for mailman id 1045625; Wed, 16 Jul 2025 20:15:55 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xj-0003uY-Fp for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:15:55 +0000 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [2a00:1450:4864:20::42a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ac6229d8-6281-11f0-b894-0df219b8e170; Wed, 16 Jul 2025 22:15:53 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3a4e62619afso29594f8f.1 for ; Wed, 16 Jul 2025 13:15:53 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:51 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ac6229d8-6281-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696952; x=1753301752; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wDovwYR+MAaNPWm/pgK0ijg6p2MZFtuj4DNgoEH65mE=; b=hmQd1gv/Rew8Tb+gemsLSE6Fv3kF59W0ImdhZi4WeaXA35dY2rfLPsIOasRykbwE3w uxrOLMdBp8JMsYQuAJhGTqWA5vDxSuoi/CegJY357mww071tfmNOkHnkKcznK6ECnK55 AtQCFPseqyQiBp+dNL1c60IrVH/ZaQMD1Z4tLwvF/God6UOv5t+W5C1X8uOVhW4xb2mK 8+j3lC/cdgLMP+2j5GdNkEN6ScJRp/JswfxMAqdRrPDiyoirGruqooMaHGV4PMdrxBBc yq5C6RVpDXGv0r9F9FmCN29S6kmQtw+omoTpouYKJMINJKSe7Pqsg/UKx29zEBLrhrRH vU8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696952; x=1753301752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wDovwYR+MAaNPWm/pgK0ijg6p2MZFtuj4DNgoEH65mE=; b=qLiOcm7deb5E1PtG0ZSvwIzxTocqny0htobN+FH6Y8kmhdu8vERQEoYOnr84n83ylg IGfmy/AJdq/7med9xa+R5G5vAGeDq5x5p8n6rjohwyrpYE3/3++AxyXy+6NOE2oqgJEm zx8AOucGSzZjfasqBHXzDNnwcNfsy7zl76tMN0KKxroev5bUZKJ9jRkHr0xbsuztflnD tNGP16FeNk3JuGHMVfM1FvEqKFw0IDxHHUTavwYVt3VArky1Dd0DZfgnaVjHVUPQ39eo bx6rRXCSBd1RcAP1J8tJ66iajJOISqrTpCszBYAcDI6MRcojCsIfF5QzEL1XMzFQYJbF In6Q== X-Gm-Message-State: AOJu0YyIzPvKC9ltQiQRZEo6l6hYIha6kINzdpyqURXGhjdGOYbCRLJf QXiqYN+FizOHtsnKGtsZ8CWZmNPFi0suty9DWNHa4druE37MDt0OGQR89/PYIg== X-Gm-Gg: ASbGncvs47FPVU+3w5THdaOH1si+roTAJ0QrDsY9+WYzJYVpmaChc2EdlShq5applRX O15HnoRX5JHwKCX1APPWupQ1jYg6d0P8bI0vdrK27UUoclwKe64r+sk1pzc/0TZvY3pPPjNSE/G JG/BQ0RpD9nERMSgfirU1twOPyn1EX7gHuBGUEVKwcpTLjhaGNyFSpvrjKDAbEco9r+cOEAikc6 v9ahvcghYDAv8nigXANLMJNsgBfWMNr3+YMh0Ezl5h95aD+E4VgCm0BOOda4WBMZUABaU/NlIuK ajA3A4aU9RPxoaEe0tvwXU7qF/GvGBDNw/567U/4p5VdASvLZ0vkX9yBrZcKe0xkCZ2fjNxfbFr FDDx2bWFuByfzm9dAgyPE72MSE5vDVN8Oy3AvBldB92ZhE6mjY2GmKbVkGLRwOtlTFEbAfZVjUt 37SGtg5GOrB3VK7Ui9MZ8Lug== X-Google-Smtp-Source: AGHT+IGxpG3wdoyGRzUda50lVJ9dEs81xzmx2MSPTheUsnsO2z97NTnLnK0KywGe78tuaGCx6lqFEg== X-Received: by 2002:a05:600c:8584:b0:455:f59e:fdab with SMTP id 5b1f17b1804b1-4562e03aa01mr13448785e9.5.1752696952034; Wed, 16 Jul 2025 13:15:52 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Nick Rosbrook , George Dunlap , Anthony PERARD , Juergen Gross Subject: [PATCH v10 1/9] tools/xl: Add altp2m_count parameter Date: Wed, 16 Jul 2025 20:15:31 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696983256116600 From: Petr Bene=C5=A1 Introduce a new altp2m_count parameter to control the maximum number of alt= p2m views a domain can use. By default, if altp2m_count is unspecified and altp= 2m is enabled, the value is set to 10, reflecting the legacy behavior. This change is preparatory; it establishes the groundwork for the feature b= ut does not activate it. Signed-off-by: Petr Bene=C5=A1 Acked-by: Nick Rosbrook Reviewed-by: Anthony PERARD --- tools/golang/xenlight/helpers.gen.go | 2 ++ tools/golang/xenlight/types.gen.go | 1 + tools/include/libxl.h | 7 +++++++ tools/libs/light/libxl_create.c | 10 ++++++++++ tools/libs/light/libxl_internal.h | 1 + tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 9 +++++++++ 7 files changed, 31 insertions(+) diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 191be87297..515a6ef10a 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -1167,6 +1167,7 @@ if err :=3D x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.m= sr_relaxed);err !=3D nil { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } x.Altp2M =3D Altp2MMode(xc.altp2m) +x.Altp2MCount =3D uint32(xc.altp2m_count) x.VmtraceBufKb =3D int(xc.vmtrace_buf_kb) if err :=3D x.Vpmu.fromC(&xc.vpmu);err !=3D nil { return fmt.Errorf("converting field Vpmu: %v", err) @@ -1695,6 +1696,7 @@ if err :=3D x.ArchX86.MsrRelaxed.toC(&xc.arch_x86.msr= _relaxed); err !=3D nil { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } xc.altp2m =3D C.libxl_altp2m_mode(x.Altp2M) +xc.altp2m_count =3D C.uint32_t(x.Altp2MCount) xc.vmtrace_buf_kb =3D C.int(x.VmtraceBufKb) if err :=3D x.Vpmu.toC(&xc.vpmu); err !=3D nil { return fmt.Errorf("converting field Vpmu: %v", err) diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index 656933c6c9..1a4f076bd2 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -604,6 +604,7 @@ ArchX86 struct { MsrRelaxed Defbool } Altp2M Altp2MMode +Altp2MCount uint32 VmtraceBufKb int Vpmu Defbool TrapUnmappedAccesses Defbool diff --git a/tools/include/libxl.h b/tools/include/libxl.h index a8704e0268..d6b6e5d2dd 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -1257,6 +1257,13 @@ typedef struct libxl__ctx libxl_ctx; */ #define LIBXL_HAVE_ALTP2M 1 =20 +/* + * LIBXL_HAVE_ALTP2M_COUNT + * If this is defined, then libxl supports setting the maximum number of + * alternate p2m tables. + */ +#define LIBXL_HAVE_ALTP2M_COUNT 1 + /* * LIBXL_HAVE_REMUS * If this is defined, then libxl supports remus. diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index 8a85fba1cf..4301f17f90 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -421,6 +421,16 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, return -ERROR_INVAL; } =20 + if (b_info->altp2m_count =3D=3D LIBXL_ALTP2M_COUNT_DEFAULT) { + if (b_info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM && + (libxl_defbool_val(b_info->u.hvm.altp2m) || + b_info->altp2m !=3D LIBXL_ALTP2M_MODE_DISABLED)) + /* Reflect the default legacy count */ + b_info->altp2m_count =3D 10; + else + b_info->altp2m_count =3D 0; + } + /* Assume that providing a bootloader user implies enabling restrict. = */ libxl_defbool_setdefault(&b_info->bootloader_restrict, !!b_info->bootloader_user); diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 75bb0b94cf..2a5b233caa 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -111,6 +111,7 @@ #define LIBXL_MIN_DOM0_MEM (128*1024) #define LIBXL_INVALID_GFN (~(uint64_t)0) #define LIBXL_VGA_HOLE_SIZE 0x20 +#define LIBXL_ALTP2M_COUNT_DEFAULT (~(uint32_t)0) /* use 0 as the domid of the toolstack domain for now */ #define LIBXL_TOOLSTACK_DOMID 0 #define QEMU_SIGNATURE "DeviceModelRecord0002" diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index a3a79d12b2..fe251649f3 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -731,6 +731,7 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ # Alternate p2m is not bound to any architecture or guest type, as it = is # supported by x86 HVM and ARM support is planned. ("altp2m", libxl_altp2m_mode), + ("altp2m_count", uint32, {'init_val': 'LIBXL_ALTP2M_COUNT_DEFAULT'}), =20 # Size of preallocated vmtrace trace buffers (in KBYTES). # Use zero value to disable this feature. diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 7e11c62ba0..28cdbf07c2 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2099,6 +2099,15 @@ void parse_config_data(const char *config_source, } } =20 + if (!xlu_cfg_get_long(config, "altp2m_count", &l, 1)) { + if (l !=3D (uint16_t)l) { + fprintf(stderr, "ERROR: invalid value %ld for \"altp2m_count\"= \n", l); + exit (1); + } + + b_info->altp2m_count =3D l; + } + if (!xlu_cfg_get_long(config, "vmtrace_buf_kb", &l, 1) && l) { b_info->vmtrace_buf_kb =3D l; } --=20 2.34.1 From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696979; cv=none; d=zohomail.com; s=zohoarc; b=F7i0fNOVgm3oc5wrCw3NnIhuEoaoaq6up6YHE5O7Qd1B2YA1ZNFXfyFOLHzhJ9TeJ5ayu72PktqOt1WLrkaHIi/bynPTXkb3+LWmBUGQM9aI0InbOHmO38RyeC34zFpph1rE+suj/nVzlvBY9zA+uijiE12jLrfa+gMr0Xpm1Cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696979; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vr3HAWcy3iR7RnCWpXjXk9ptcqN2sMtjI1FfiwT4ilQ=; b=icpDRoCCF0tsOFD+zmDxL9ZP6RKZUnbTpqI0hm1y22DskS8vyGdw0vWdgtg5umQmgOO9RhhcZtMFIrapPq8CeogHTu0C3NWYvGK/E4X/jbG++h93Kb5aJnGV1I3V5DykzoqsYy2IX+5avLe6B0oQA4iGi3OvfkR7ISmwnDIUlB4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1752696979562690.4849323308679; Wed, 16 Jul 2025 13:16:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045623.1415765 (Exim 4.92) (envelope-from ) id 1uc8Xk-0003v1-Gz; Wed, 16 Jul 2025 20:15:56 +0000 Received: by outflank-mailman (output) from mailman id 1045623.1415765; Wed, 16 Jul 2025 20:15:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xk-0003uu-EI; Wed, 16 Jul 2025 20:15:56 +0000 Received: by outflank-mailman (input) for mailman id 1045623; Wed, 16 Jul 2025 20:15:55 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xi-0003uZ-Uh for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:15:54 +0000 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [2a00:1450:4864:20::42c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id acbf28cc-6281-11f0-a319-13f23c93f187; Wed, 16 Jul 2025 22:15:53 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3b39c46e1cfso32353f8f.3 for ; Wed, 16 Jul 2025 13:15:53 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:52 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: acbf28cc-6281-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696953; x=1753301753; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vr3HAWcy3iR7RnCWpXjXk9ptcqN2sMtjI1FfiwT4ilQ=; b=ZFrA7ZpBv4duqpUQ2MMsy0F9jSXlnTFF9Wmyr2Uz/hF7wGUwQTiKdQO679XdiJPpYc qbJkbdueTE5l4U7rRSy5QorjCy+fBtOkfOPtDmT2jvY3GXb4f06UmNv4PT1tqf0vK0ui 1eSaiByXSQazzAqTp5qDNQWH56Fj/zlC/zwprMQPhtR8MzqGYFe8tJtzYyZNe1Mgwl3Z /iO9o0v4D1x/PFQ1Im9nfuh87PYIZQkxsFy4nsFSrQSWbYDoc9rewLp9mEhkazwmvsyt hxRdF+eF9YhjPWW08bLfoAQqXEaDSlc8E3EBvxqOtXV/AJuQueCTjkZlZ/9jwA/Foq6E 3v+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696953; x=1753301753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vr3HAWcy3iR7RnCWpXjXk9ptcqN2sMtjI1FfiwT4ilQ=; b=hAfgIi3hWLisEAWS4QKnwnaaozMp5K6VSdPLbvZvsPb9oRw2Y2q1bwUtIFVfPTPj5b 5o5Lq+kDZMGFohbkgHnxJl0o2W5YqiAORFoJ7WD8LcUAJlldY1J+eLf3uQuKuYLc9RBr L9rtlYhlgQFipdPDVhGjLrslhfmXeQOZshHzi/xMLjWAbPrY/Xk5z/Oa3Ic4oxv43bX4 rgOlCZyTR9LUxAVbIp+gWQ8SHIAmnprzAvhgsthYIFK2nUnrgYFV9vA2OTGa2hDAeqY4 oFyvToA553MqxUg7BWwko173NUMGDWwfz9+TvnBVHQZIsIDUHCE5tFL2VajGZ+03DWLj t6gQ== X-Gm-Message-State: AOJu0YwY6w2OCrtP8LJtgl0qqaYfQ9l05w4VF946a9OEOD1LeHNYjHu9 EtuAgknDYLb0Cl+uEX8dg4UOrFRgEHJZcOXkp2Y+x3V5fEYNMP/YrSxkOZvCDQ== X-Gm-Gg: ASbGnctTah4Us1Q/cNk98Jv1OXHpV7GjudDYTHXTkc3fD0JD2DCQhWr8dy0QoIeNEGY 7T464RQb6fyZJZEk+WJRY4Oaaj06IGviho8daHOy6eLswQkI/tY2IfZU4wQl+0j3MY5Qv7RHRlF IqTB0bNnNTmgE12Hv7yHsrD866iWm0h8JgRQtaGiIxeWyUrzIAqwx7KJnf1YCAKk3Wfr/46sUUW j6YOg1GRRjvzrL2wiKm5BzUCiCIINpSPnnwbBZ647amizsgu4L9KkqSyznWebJQeOo7wQ/36JSY SgFTZPOK7JXfGCv2JE/tA2l0tNJcgk83fdxl7mW1YrZLAt9NLekfAHXxlIpKM0aYE2Zdl567li5 dEGdm3iVETiqvZgc7FNiDn1Mil2W40IUxNScOjih2Y+KOAwVBETR+MkQnzIn8wAZsb5aTIlnRiB LlenDUbHCuh39KAg3Co2/L8w== X-Google-Smtp-Source: AGHT+IHNXfcNe0myIz2D3lhRJdy2pFf2m1UWPB8saOVgP9AD1JAbBH+BBtmj35TCCkDj3ChfnyZU5Q== X-Received: by 2002:a5d:64e2:0:b0:3a5:2dae:970f with SMTP id ffacd0b85a97d-3b60dd81736mr1506879f8f.13.1752696952748; Wed, 16 Jul 2025 13:15:52 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Anthony PERARD Subject: [PATCH v10 2/9] docs/man: Add altp2m_count parameter to the xl.cfg manual Date: Wed, 16 Jul 2025 20:15:32 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696981252116600 From: Petr Bene=C5=A1 Update manual pages to include detailed information about the altp2m_count configuration parameter. Signed-off-by: Petr Bene=C5=A1 Acked-by: Anthony PERARD --- docs/man/xl.cfg.5.pod.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 1d122982c6..5362fb0e9a 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2023,6 +2023,20 @@ a single guest HVM domain. B: While the option "altp2mhvm" is deprecated, legacy applications f= or x86 systems will continue to work using it. =20 +=3Ditem B + +Specifies the maximum number of alternate-p2m views available to the guest. +This setting is crucial in domain introspection scenarios that require +multiple physical-to-machine (p2m) memory mappings to be established +simultaneously. + +Enabling multiple p2m views may increase memory usage. It is advisable to +review and adjust the B setting as necessary to accommodate +the additional memory requirements. + +B: This option is ignored if B is disabled. The default value +is 10. + =3Ditem B =20 Enable or disables guest access to hardware virtualisation features, --=20 2.34.1 From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696979; cv=none; d=zohomail.com; s=zohoarc; b=dM5wgx9QZLWPMSRUAKrE7Ti7t0moS7HaDpyS2lZGLnuHCjQq1dyWvSa2pvkkMmqUQ1vCORSfAemYYrttEyn/Ji5UQxJAqP+8A4aqwXsjbUMMP05+tYlPKkLJuquDWjKeiRk63J1Y3uDbb2pMC7Q8wdEryVIjeB9MIR/Krpa9Y+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696979; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IzTo23Sx/OEupN9XRs7aPIsAXHXRXpmD+YzCJ1BbJWk=; b=lup7Ufr8AJwAJF1w4RWQgWU+RG+iQtliBBjKhHomaPQukUjJSqVd0UYKhRw2B1P6Sou6Yu1IaDbBxzi6BFWlsYsLtY9U1OnvShY29pidpsxAQYYnHuj6AE2RHtHznbYIxMa7hO+f2iMwTPQSSFkhKXm7CsmhkStFfjshCsXe/CA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1752696979810318.59567492090866; Wed, 16 Jul 2025 13:16:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045626.1415781 (Exim 4.92) (envelope-from ) id 1uc8Xl-0004AH-CZ; Wed, 16 Jul 2025 20:15:57 +0000 Received: by outflank-mailman (output) from mailman id 1045626.1415781; Wed, 16 Jul 2025 20:15:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xl-00049C-7e; Wed, 16 Jul 2025 20:15:57 +0000 Received: by outflank-mailman (input) for mailman id 1045626; Wed, 16 Jul 2025 20:15:55 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xj-0003uZ-IS for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:15:55 +0000 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [2a00:1450:4864:20::435]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ad226a9e-6281-11f0-a319-13f23c93f187; Wed, 16 Jul 2025 22:15:54 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3b60565d5f4so21581f8f.0 for ; Wed, 16 Jul 2025 13:15:54 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:53 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ad226a9e-6281-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696954; x=1753301754; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IzTo23Sx/OEupN9XRs7aPIsAXHXRXpmD+YzCJ1BbJWk=; b=NzCE/gHXPwHwWx/jHmBvG3sE+XJuQ3cPySRNbByfjElxtpnzqQ4XQh5753nnfTCojw 67PNDRqqAqCM98gf/ARcRjswsJHtWpgdwZ88zFEyPx0RmASXSl0VifvejGMsxSBr9UTa hVSkPmR6LH1PrCZoLtBpzynf6IxR4WYwuLwR16ISs6eEttru8TxXazIWAN3p8ZsWqhf+ PLo+VwKLCQMK0jsuLLucU8ZUBEo7pCjjf+j2HiBlvPJbKu82kdivX70nTlbOhDW4K1TV /cmRtU+caTiauDfNbULVLBbMud8J9+IsNQ3uaSl/n5Tdh2eChRqFPRJNmfolZuFQ2LOG okDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696954; x=1753301754; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IzTo23Sx/OEupN9XRs7aPIsAXHXRXpmD+YzCJ1BbJWk=; b=GcfBhx/q1qI1qoP7/ikT5yHh6DdYZrpc0GUmKIUmiSTiZD6YvOP/RE6R1+jsA3hYrP iAXuZPdrV4RRxPqzt2Pu4jD4sw9DaNW3JIe2vFaVjsKCJ0FRJBhSJ3+Q3MbxX/DFAt/k 68UvRdaQxmoeEuprReaxqRr3t6+KDbyYTUtu6daVXFAUS/S3jxFHx8gMEgCx1mXWWPC0 FQAWVu3/3BvQLqbtWiFIduW5+Rhy1r5lHLjsflqdtDQzVsQdnr3oO3cECYgPMi+AB6+4 lXyHTUCHCpSuMuEQPJEd/KQJnc+imuEGaB7UKF0zOaHHeb3KI6sAWJJ2NTjK0J85qUPi ky6A== X-Gm-Message-State: AOJu0YxR+gO8mVLgLNnsJEhT9LPBCV4DMVyVc81xI/v01VkGUuJGZ4cX WabIyah2tFyOJS7fXW5iEjr7Unsy6kalKBD6VU1/R6rM3Afez8S4WQcmBM9cfg== X-Gm-Gg: ASbGnctz5nKTZCWVEnFOn3N/0967P2Q7QlW/nrTsrc+ha6FczzKgwjKqjr0GCuw9HiR eAPgZOwsOAdiMH9XZKmI/qbsX+YCzLVbq89jdwLF5N/FJgfOWaZ9EVTDlun5yFNfFhmE5VIol02 B1PMKUltrj0k7jLWAQM4MejnrhYubfKAt58KxMHlVdN6xirSG1mRJL/KFZjIAY7+taGka7P6HRq LoGm2WhrfEAtzm/GH7TkxqrkDnLHXg32YLlLTAwD2L2q2a6B4U/v1HWGZ6hVLyj08j2YUyVsBIk sNKQtquG/TEVeXXv5etQQKDmwnpaOOsjtJY0YDgXEkIvvgh9JCTcbDDLgpKLptgZd2ax+vX2JTH qi1Wzy6sIMgm/GHs4AmH6N1c/VDLVP1TJ4+OOQJiUMRksM3YWV+yQZnhDc4vscPEzaA9ZJg24Gu 9I/m5hmRLySpeR4NcR//7JTg== X-Google-Smtp-Source: AGHT+IGUg2sOHjk/UznLZOKAg4XbtujlsyagSGNiX7D3hOlc6Ylmj+FAHvFVmCjIKetKab9fedznRA== X-Received: by 2002:a05:600c:1c16:b0:453:c08:a1fa with SMTP id 5b1f17b1804b1-4562df5475dmr17455585e9.0.1752696953569; Wed, 16 Jul 2025 13:15:53 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v10 3/9] x86/p2m: Short-circuit p2m_is_altp2m() when CONFIG_ALTP2M=n Date: Wed, 16 Jul 2025 20:15:33 +0000 Message-Id: <4da736fc96d0d8ee717156957b3e8aa9aec92797.1752691429.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696981233116600 From: Petr Bene=C5=A1 Wrap the p2m_is_altp2m() check with IS_ENABLED(CONFIG_ALTP2M) to allow the compiler to short-circuit the condition at build time when ALTP2M is disabl= ed. Signed-off-by: Petr Bene=C5=A1 Reviewed-by: Jan Beulich --- xen/arch/x86/include/asm/p2m.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 4358cc15a2..58b56e575e 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -437,7 +437,7 @@ static inline bool p2m_is_nestedp2m(const struct p2m_do= main *p2m) =20 static inline bool p2m_is_altp2m(const struct p2m_domain *p2m) { - return p2m->p2m_class =3D=3D p2m_alternate; + return IS_ENABLED(CONFIG_ALTP2M) && p2m->p2m_class =3D=3D p2m_alternat= e; } =20 #ifdef CONFIG_HVM --=20 2.34.1 From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696987; cv=none; d=zohomail.com; s=zohoarc; b=gVtX9iQP8v78CenqS69Jw7uP3kNyq008BwwqSLfVmlFJH6Gy8XNHMRtgOnvC9AjpF2I4IR6p5C5MxN1p0zTMkDvKOlhSGgemsCV1e3Mp0goAjSVHqH7GuoDN8f+u7gp91lhZJDQ7FLq5xigrQ3MfWcqFadNtQvMJtefnFi5x6B4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696987; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OOOuvJZYZXWyW3TNAhVhGpb6GbfsoYMK9X46Miiu2ok=; b=hHPdxjm2oA6QN00OF+dOTvSdHZSnDIdvAhPuM3WEPg74M0hW0+WzgTqL9+KXk0dZmIx4e3M6BHQlNNdkUnObGkHYh+vVQhqH9Ol/yr8io/dnIBAqTfX9/4s/TZ5LS22H238Si3JY7dvY+/zLoJbwxPTNhoyt4mAaloIsjSq0/Mo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1752696987577537.3427903886588; Wed, 16 Jul 2025 13:16:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045627.1415791 (Exim 4.92) (envelope-from ) id 1uc8Xl-0004Md-SS; Wed, 16 Jul 2025 20:15:57 +0000 Received: by outflank-mailman (output) from mailman id 1045627.1415791; Wed, 16 Jul 2025 20:15:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xl-0004Jd-NX; Wed, 16 Jul 2025 20:15:57 +0000 Received: by outflank-mailman (input) for mailman id 1045627; Wed, 16 Jul 2025 20:15:56 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xk-0003uZ-IS for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:15:56 +0000 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [2a00:1450:4864:20::430]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ae08f426-6281-11f0-a319-13f23c93f187; Wed, 16 Jul 2025 22:15:56 +0200 (CEST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3a4e57d018cso22315f8f.1 for ; Wed, 16 Jul 2025 13:15:56 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:54 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ae08f426-6281-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696955; x=1753301755; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OOOuvJZYZXWyW3TNAhVhGpb6GbfsoYMK9X46Miiu2ok=; b=Tk4Y9bNmuBiUKX4XRhaPWKKDR0m6u6JON4totcjUEDoTthhM3YckfxXlYFeRCyXowl NUrIbfF4pLiKg2OkN/OX8okDM7oBaLOQuWZJ3u+e9mSjDXOZcBGnJowvugHjOKFK9EaX V53WlMWlCLtpzTdfge/LAVlKSDLa2PQhBJsF6ZflwaKrncw7ABdf5y2Sj682GQeQv19U 7GsLWqGruxMXO7kFT2L3iExl1VbNgTbZ1kGhss/v7PN9YCEalrrZ7m3HHP4gTVm4Ksod NGOXtREpUnDB6HgPKR9y/gHveoKCsGcVRb7g58ywslsG4zBoNAPX0YvpV7NSbEAdn5PW RC0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696955; x=1753301755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OOOuvJZYZXWyW3TNAhVhGpb6GbfsoYMK9X46Miiu2ok=; b=d60ge1uKFuIsHD3MhNQF/ZH5iuT3hqhYW7LshRgQho9P503V2qPcXsVouwfmpKJAmz HwZKhJclVlM3Ew+B6D3HbMv1xfOxfEszdlYe+9ZA2dj4wsGWW2XSfj+xQM4r8OH9iBfP pRsaCAIHvJ/S4yP70ii236COU5av1OIKCyk/E1kNv6gNxF4BC8S+F+7wZdC9t/ggUYMi 45BrJ5yBkf1NeVZK9XGg4sRnD6fJfqEwlNzdb3j430Ph+3vBthpV0PlHuyIu44vH6B8D u7I23aZb3aW4YZMVQkZqcM33MGZ5Eb+SzAkSLF53zs6kIIKEHc/jJIcXEKtuenC5kjJO nQSg== X-Gm-Message-State: AOJu0YyOTHsWoGIgMs7A546RYYOn2AMa3WlSzf1cZsWhl5iVDf/O0Hvo lxOHXTQWcH0fAWYp1hDgNghBvPLBrtAo0+WLf+qZ8vrTodvOHeMwmo1SmV+Vow== X-Gm-Gg: ASbGncsrsxGWtSmIX78TLdfZ0L9WMKfA30QaUy/83lp7cSwHU71Ex9ySEwM99LtOZJ3 7TDqM0Da+cv8tuli4QRZ+/+zUzlJD3nFQnW7xfgn0zepqFr1jje3COb1CcvZZwTg9LwHJ0Ae8lp fBKuCavR5G2TUMhRoUvTsNeL7oVio/Z8OCT1R/vSM3r1SUUlrDmZ9pMv+BMSZyUt2D0NIP875/T iGP4sszVLhvicLvrSVUp8LbSl5xFua/AcEIOOUj+UUSFSnK5aw75b9cAcWTAT7pNQbqbU26Ugzg 8rqA6ofRYX2iYnzPhKSggP/s2Qe/OeF9t5JDV3et6oPv0vo4y+fjfphsbBuH75m3OUQ/+6p0U+8 alHI0AgEt1VEwKzdd8kD1ZAQ7whTDcYRRimnLI3ZZcgjyhneMx1hEvYqDmMvZAbXvG3H4psVqa2 HSpoX0HZ63qvbVyLDi4xNqhg== X-Google-Smtp-Source: AGHT+IHe33aKatrvuakEauHcsqKPfkwsS7bKer6g4mjhfSUEZ/C0u+ncTGyA8RtCy14IPsBduuTpMg== X-Received: by 2002:a05:600c:4f0c:b0:442:e608:12a6 with SMTP id 5b1f17b1804b1-4562dff98b5mr19593435e9.1.1752696954808; Wed, 16 Jul 2025 13:15:54 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Shawn Anastasio , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v10 4/9] x86/altp2m: Remove p2m_altp2m_check stubs from unsupported architectures Date: Wed, 16 Jul 2025 20:15:34 +0000 Message-Id: <3c46e6bd09b2481360fbdf812926d199c5416198.1752691429.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696989271116600 From: Petr Bene=C5=A1 The p2m_altp2m_check() stub was previously declared on all architectures, even though the altp2m feature is only supported on x86. This patch removes the unused stub definitions from ARM, PPC, and RISC-V, and wraps the actual usage sites in #ifdef CONFIG_ALTP2M instead. Additionally, the declaration and definition of p2m_altp2m_check() are now correctly nested under CONFIG_HVM, reflecting the fact that CONFIG_ALTP2M always implies CONFIG_HVM. Signed-off-by: Petr Bene=C5=A1 --- xen/arch/arm/include/asm/p2m.h | 6 ------ xen/arch/ppc/include/asm/p2m.h | 5 ----- xen/arch/riscv/include/asm/p2m.h | 5 ----- xen/arch/x86/hvm/monitor.c | 2 ++ xen/arch/x86/include/asm/p2m.h | 9 ++++----- xen/common/vm_event.c | 2 ++ 6 files changed, 8 insertions(+), 21 deletions(-) diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h index 2d53bf9b61..ef98bc5f4d 100644 --- a/xen/arch/arm/include/asm/p2m.h +++ b/xen/arch/arm/include/asm/p2m.h @@ -180,12 +180,6 @@ static inline bool arch_acquire_resource_check(struct = domain *d) return true; } =20 -static inline -void p2m_altp2m_check(struct vcpu *v, uint16_t idx) -{ - /* Not supported on ARM. */ -} - /* * Helper to restrict "p2m_ipa_bits" according the external entity * (e.g. IOMMU) requirements. diff --git a/xen/arch/ppc/include/asm/p2m.h b/xen/arch/ppc/include/asm/p2m.h index f144ef8e1a..c96149ef74 100644 --- a/xen/arch/ppc/include/asm/p2m.h +++ b/xen/arch/ppc/include/asm/p2m.h @@ -88,9 +88,4 @@ static inline bool arch_acquire_resource_check(struct dom= ain *d) return false; } =20 -static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) -{ - /* Not supported on PPC. */ -} - #endif /* __ASM_PPC_P2M_H__ */ diff --git a/xen/arch/riscv/include/asm/p2m.h b/xen/arch/riscv/include/asm/= p2m.h index 28f57a74f2..e43c559e0c 100644 --- a/xen/arch/riscv/include/asm/p2m.h +++ b/xen/arch/riscv/include/asm/p2m.h @@ -88,11 +88,6 @@ static inline bool arch_acquire_resource_check(struct do= main *d) return false; } =20 -static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) -{ - /* Not supported on RISCV. */ -} - #endif /* ASM__RISCV__P2M_H */ =20 /* diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c index 523586ca98..d22a2e4644 100644 --- a/xen/arch/x86/hvm/monitor.c +++ b/xen/arch/x86/hvm/monitor.c @@ -178,6 +178,7 @@ int hvm_monitor_debug(unsigned long rip, enum hvm_monit= or_debug_type type, break; =20 case HVM_MONITOR_SINGLESTEP_BREAKPOINT: +#ifdef CONFIG_ALTP2M if ( curr->arch.hvm.fast_single_step.enabled ) { p2m_altp2m_check(curr, curr->arch.hvm.fast_single_step.p2midx); @@ -186,6 +187,7 @@ int hvm_monitor_debug(unsigned long rip, enum hvm_monit= or_debug_type type, curr->arch.hvm.fast_single_step.p2midx =3D 0; return 0; } +#endif if ( !ad->monitor.singlestep_enabled ) return 0; req.reason =3D VM_EVENT_REASON_SINGLESTEP; diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 58b56e575e..7375895836 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -962,17 +962,16 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn= _t gfn, /* Set a specific p2m view visibility */ int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int altp2m_i= dx, uint8_t visible); -#else /* !CONFIG_HVM */ -struct p2m_domain *p2m_get_altp2m(struct vcpu *v); -#endif /* CONFIG_HVM */ =20 #ifdef CONFIG_ALTP2M /* Check to see if vcpu should be switched to a different p2m. */ void p2m_altp2m_check(struct vcpu *v, uint16_t idx); -#else -static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) {} #endif =20 +#else /* !CONFIG_HVM */ +struct p2m_domain *p2m_get_altp2m(struct vcpu *v); +#endif /* CONFIG_HVM */ + /* p2m access to IOMMU flags */ static inline unsigned int p2m_access_to_iommu_flags(p2m_access_t p2ma) { diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 1666ff615f..98204cbf43 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -430,9 +430,11 @@ static int vm_event_resume(struct domain *d, struct vm= _event_domain *ved) */ vm_event_toggle_singlestep(d, v, &rsp); =20 +#ifdef CONFIG_ALTP2M /* Check for altp2m switch */ if ( rsp.flags & VM_EVENT_FLAG_ALTERNATE_P2M ) p2m_altp2m_check(v, rsp.altp2m_idx); +#endif =20 if ( rsp.flags & VM_EVENT_FLAG_SET_REGISTERS ) vm_event_set_registers(v, &rsp); --=20 2.34.1 From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696975; cv=none; d=zohomail.com; s=zohoarc; b=DxaiWjnIjobbJ5g6mnAHvN681Mg+6a3c9uMXBEvOsb/ZbYLzw2nZ4KUtnXEb6J5o8hKkFxG3be/CBSd8C8SNaNNYZM1eXztUgm8KizwA4/h7dVjzxYiZu0y1q744ZvebQdz6SuQQ66t6D3zbQHqoSsrDA82cP+Jj7KKetmInIp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696975; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oSrj1Q8+f2dC3e/O+6UnVyN9VNRU5k/bRaULjt3iNhY=; b=i46GYlJ0LdmBVII65LQeE9Xxp5QiKlKU47xSmo/NFV6ROuMaGePNtTFzu+U+QGSvs+kpkZAqAnctGLs0qt609vL2SfpFDesn/RwZMp2PLzeOU37o41hlhXuziiy58PD17GFgoCHeNxE1F8aiW8pL++8eBE+j2NByK9ukzAtBA94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17526969751296.218996343212893; Wed, 16 Jul 2025 13:16:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045628.1415815 (Exim 4.92) (envelope-from ) id 1uc8Xo-00053G-Ay; Wed, 16 Jul 2025 20:16:00 +0000 Received: by outflank-mailman (output) from mailman id 1045628.1415815; Wed, 16 Jul 2025 20:16:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xo-000537-6a; Wed, 16 Jul 2025 20:16:00 +0000 Received: by outflank-mailman (input) for mailman id 1045628; Wed, 16 Jul 2025 20:15:58 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xm-0003uY-NS for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:15:58 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ae87420f-6281-11f0-b894-0df219b8e170; Wed, 16 Jul 2025 22:15:56 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4535fc0485dso426705e9.0 for ; Wed, 16 Jul 2025 13:15:56 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:55 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ae87420f-6281-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696956; x=1753301756; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oSrj1Q8+f2dC3e/O+6UnVyN9VNRU5k/bRaULjt3iNhY=; b=DcEbZdDG2uXo2MR9vbyMxrSjCcJoxZ/qxpzBrfUkj2+8yogXh0rWHRkdCSDJMGzpQi nRtIIXyt6HhPbP19y14Gqig3y7gOnfsk//xhX8O0e8JONwRsbjYD/BZlMdcqqQXE2w2X B4qoBTRcJS3dSALSLjCU6U7AJxcFC2ufa9J0UYV3veDbb71MLP0cRw++n884aD3mrsAZ cOw0UgqpR6ITXyrYLEPBaA7qK0jk9poyppTIO15XnCqylGJrwPriNK0EeATLDpoWbuO3 3Y2E9yl/wxhbpHN07JfrIBOt6+RpzSc7DWaRH7MJyc8Rm8IvYOQ/KJfFAiFz6IZhSMLO L20Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696956; x=1753301756; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oSrj1Q8+f2dC3e/O+6UnVyN9VNRU5k/bRaULjt3iNhY=; b=JkiYfO8a5F00uiyfCtyHID+XrjGyK8AU6SkejD6LeES7/NkqxQjaVsmUjafVwi6Q8b Pgrhjpr+MiORLgPyFiaGJOjSopvSVRUImiG9Ez53iPDL3VHv6Ho/4uMdGkxF4FOUq6dI 4W+SCFwxwmkC3X5Tm1i4Dzqe3kwYEvP8P/VXzZZp/j5BYTWizO1a0FMsp3z+IBdBsc3V oBDlaewqWsS38uiJ8kPHhEe0iD1Lc/HHwFAuk10jINbfzzHrsZJzQMUBXXGpQ/mosN8w QPxNj5tTrScmMeCBvN5MJ9wTACIXeKeKpO2+BqOpBnyPZDEjQWIJ6k1YdP/gIobDOcQp ZI9g== X-Gm-Message-State: AOJu0YxByHfwwNVIeFKctra78I/6gSU8LO8bg293r5ymrfHdWbuD2Ff+ oO1T9QA/o/28ptok42fG93BS+1mOHAJ0K7GWaiz3UKG7Kk+s3E0oadl3t+8QIQ== X-Gm-Gg: ASbGncuk/EIywcxDM15ZbePLtjNVNecST7dmfnuGpA0kzD7eW7TR1NZIkvV1Ak8dEmp mUlCKrZLU45Zlf0uL1220Lvcg9AI9EO2YXpHlS/Dyk8gkoEoahJeQLi4SaHXFWXNdyTI4GxdF24 Rxmn0Rs7ekMTbFEdTGGbSGglTxdenr1XGTsRUvh4hXiiy/XBEgW2mTgjV86iHRg72gtZssOkV3R krZUTUcCwXziY5izn8jtz8EpR2M56WdPGDItSX4ZD8Q3GuM9G8K6MRf0nv15IoBHCWFm5Pb2xoT 2lXR2URuM1OkGqx4bD73XQIYUfIStM8eP18TAjkLyp2T7XxYfWnzQkbT4tdzCHt5E4L1xX9jkJO VT1rN99A2/Mx0RV2+FpRe9lRqsXN8kqOI83TY2vsw5ANti4WtZrh91uMKT62kN+BJyoqN+IjcYI G4PoatDN3NZRtHS+W3wi/flQ== X-Google-Smtp-Source: AGHT+IEf9Eg95JbsVko17BZpPVO1ysf/Tzl8zVpTsn/OD2tBB86LNZNvpyO079mVqPFJ+RjyRScS5w== X-Received: by 2002:a05:6000:2c06:b0:3a3:6a3f:bc61 with SMTP id ffacd0b85a97d-3b60dd65f3fmr1580168f8f.7.1752696955707; Wed, 16 Jul 2025 13:15:55 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu Subject: [PATCH v10 5/9] x86/altp2m: Wrap altp2m-specific code in #ifdef CONFIG_ALTP2M Date: Wed, 16 Jul 2025 20:15:35 +0000 Message-Id: <35028b36429edbff5f6bf1af6a8168ac055089bd.1752691429.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696977373116600 From: Petr Bene=C5=A1 This change consistently guards all altp2m-related functionality behind #ifdef CONFIG_ALTP2M, so that code and data structures related to alternate p2m views are only included when the feature is enabled. Apart from that: - hvmemul_vmfunc() returns X86EMUL_UNHANDLEABLE when altp2m is disabled. - do_altp2m_op() returns EOPNOTSUPP when altp2m is disabled. - struct hvm_vcpu, arch_domain, and hvm_function_table only define altp2m fields when the feature is enabled. - Moved several declarations under #ifdef CONFIG_ALTP2M in p2m.h to avoid polluting builds that don't require the feature. Signed-off-by: Petr Bene=C5=A1 --- xen/arch/x86/hvm/emulate.c | 10 ++++++++-- xen/arch/x86/hvm/hvm.c | 10 ++++++++++ xen/arch/x86/hvm/vmx/vmx.c | 8 ++++++++ xen/arch/x86/include/asm/domain.h | 2 ++ xen/arch/x86/include/asm/hvm/hvm.h | 8 ++++++++ xen/arch/x86/include/asm/hvm/vcpu.h | 4 ++++ xen/arch/x86/include/asm/p2m.h | 17 ++++++++++++++--- xen/arch/x86/mm/hap/hap.c | 6 ++++++ xen/arch/x86/mm/mem_access.c | 8 ++++++++ xen/arch/x86/mm/p2m-ept.c | 4 ++++ xen/arch/x86/mm/p2m.c | 9 +++++++++ 11 files changed, 81 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 91f004d233..d933ed3bd3 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -2686,8 +2686,8 @@ static int cf_check hvmemul_tlb_op( return rc; } =20 -static int cf_check hvmemul_vmfunc( - struct x86_emulate_ctxt *ctxt) +#ifdef CONFIG_ALTP2M +static int cf_check hvmemul_vmfunc(struct x86_emulate_ctxt *ctxt) { int rc; =20 @@ -2699,6 +2699,12 @@ static int cf_check hvmemul_vmfunc( =20 return rc; } +#else +static int cf_check hvmemul_vmfunc(struct x86_emulate_ctxt *ctxt) +{ + return X86EMUL_UNHANDLEABLE; +} +#endif =20 static const struct x86_emulate_ops hvm_emulate_ops =3D { .read =3D hvmemul_read, diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 56c7de3977..5183bfea3a 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4608,6 +4608,7 @@ static int hvmop_get_param( static int do_altp2m_op( XEN_GUEST_HANDLE_PARAM(void) arg) { +#ifdef CONFIG_ALTP2M struct xen_hvm_altp2m_op a; struct domain *d =3D NULL; int rc =3D 0; @@ -4944,6 +4945,9 @@ static int do_altp2m_op( rcu_unlock_domain(d); =20 return rc; +#else /* !CONFIG_ALTP2M */ + return -EOPNOTSUPP; +#endif /* CONFIG_ALTP2M */ } =20 DEFINE_XEN_GUEST_HANDLE(compat_hvm_altp2m_op_t); @@ -5235,8 +5239,12 @@ int hvm_debug_op(struct vcpu *v, int32_t op) =20 case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF: v->arch.hvm.single_step =3D false; + +#ifdef CONFIG_ALTP2M v->arch.hvm.fast_single_step.enabled =3D false; v->arch.hvm.fast_single_step.p2midx =3D 0; +#endif + break; =20 default: /* Excluded above */ @@ -5261,6 +5269,7 @@ void hvm_toggle_singlestep(struct vcpu *v) =20 void hvm_fast_singlestep(struct vcpu *v, uint16_t p2midx) { +#ifdef CONFIG_ALTP2M ASSERT(atomic_read(&v->pause_count)); =20 if ( !hvm_is_singlestep_supported() ) @@ -5272,6 +5281,7 @@ void hvm_fast_singlestep(struct vcpu *v, uint16_t p2m= idx) v->arch.hvm.single_step =3D true; v->arch.hvm.fast_single_step.enabled =3D true; v->arch.hvm.fast_single_step.p2midx =3D p2midx; +#endif } =20 /* diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 218cb2c1af..b136d89546 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2416,6 +2416,8 @@ static void cf_check vmx_enable_msr_interception(stru= ct domain *d, uint32_t msr) vmx_set_msr_intercept(v, msr, VMX_MSR_W); } =20 +#ifdef CONFIG_ALTP2M + static void cf_check vmx_vcpu_update_eptp(struct vcpu *v) { struct domain *d =3D v->domain; @@ -2535,6 +2537,8 @@ static bool cf_check vmx_vcpu_emulate_ve(struct vcpu = *v) return rc; } =20 +#endif /* CONFIG_ALTP2M */ + static bool cf_check vmx_get_pending_event( struct vcpu *v, struct x86_event *info) { @@ -2863,10 +2867,12 @@ static struct hvm_function_table __initdata_cf_clob= ber vmx_function_table =3D { .update_vlapic_mode =3D vmx_vlapic_msr_changed, .nhvm_hap_walk_L1_p2m =3D nvmx_hap_walk_L1_p2m, .enable_msr_interception =3D vmx_enable_msr_interception, +#ifdef CONFIG_ALTP2M .altp2m_vcpu_update_p2m =3D vmx_vcpu_update_eptp, .altp2m_vcpu_update_vmfunc_ve =3D vmx_vcpu_update_vmfunc_ve, .altp2m_vcpu_emulate_ve =3D vmx_vcpu_emulate_ve, .altp2m_vcpu_emulate_vmfunc =3D vmx_vcpu_emulate_vmfunc, +#endif .vmtrace_control =3D vmtrace_control, .vmtrace_output_position =3D vmtrace_output_position, .vmtrace_set_option =3D vmtrace_set_option, @@ -4963,6 +4969,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_u= ser_regs *regs) single =3D ept; } =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(currd) ) { unsigned int i; @@ -4981,6 +4988,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_u= ser_regs *regs) } } } +#endif =20 if ( inv ) __invept(inv =3D=3D 1 ? INVEPT_SINGLE_CONTEXT : INVEPT_ALL_CON= TEXT, diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index 8c0dea12a5..8749c5eba0 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -351,12 +351,14 @@ struct arch_domain struct p2m_domain *nested_p2m[MAX_NESTEDP2M]; mm_lock_t nested_p2m_lock; =20 +#ifdef CONFIG_ALTP2M /* altp2m: allow multiple copies of host p2m */ bool altp2m_active; struct p2m_domain *altp2m_p2m[MAX_ALTP2M]; mm_lock_t altp2m_list_lock; uint64_t *altp2m_eptp; uint64_t *altp2m_visible_eptp; +#endif #endif =20 /* NB. protected by d->event_lock and by irq_desc[irq].lock */ diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/= hvm/hvm.h index bf8bc2e100..af80acfdd8 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -225,11 +225,13 @@ struct hvm_function_table { =20 void (*enable_msr_interception)(struct domain *d, uint32_t msr); =20 +#ifdef CONFIG_ALTP2M /* Alternate p2m */ void (*altp2m_vcpu_update_p2m)(struct vcpu *v); void (*altp2m_vcpu_update_vmfunc_ve)(struct vcpu *v); bool (*altp2m_vcpu_emulate_ve)(struct vcpu *v); int (*altp2m_vcpu_emulate_vmfunc)(const struct cpu_user_regs *regs); +#endif =20 /* vmtrace */ int (*vmtrace_control)(struct vcpu *v, bool enable, bool reset); @@ -707,6 +709,7 @@ static inline bool hvm_nested_virt_supported(void) return hvm_funcs.caps.nested_virt; } =20 +#ifdef CONFIG_ALTP2M /* updates the current hardware p2m */ static inline void altp2m_vcpu_update_p2m(struct vcpu *v) { @@ -731,6 +734,11 @@ static inline bool altp2m_vcpu_emulate_ve(struct vcpu = *v) } return false; } +#else /* !CONFIG_ALTP2M */ +void altp2m_vcpu_update_p2m(struct vcpu *v); +void altp2m_vcpu_update_vmfunc_ve(struct vcpu *v); +bool altp2m_vcpu_emulate_ve(struct vcpu *v); +#endif /* CONFIG_ALTP2M */ =20 static inline int hvm_vmtrace_control(struct vcpu *v, bool enable, bool re= set) { diff --git a/xen/arch/x86/include/asm/hvm/vcpu.h b/xen/arch/x86/include/asm= /hvm/vcpu.h index 196fed6d5d..924af890c5 100644 --- a/xen/arch/x86/include/asm/hvm/vcpu.h +++ b/xen/arch/x86/include/asm/hvm/vcpu.h @@ -133,10 +133,12 @@ struct hvm_vcpu { bool flag_dr_dirty; bool debug_state_latch; bool single_step; +#ifdef CONFIG_ALTP2M struct { bool enabled; uint16_t p2midx; } fast_single_step; +#endif =20 /* (MFN) hypervisor page table */ pagetable_t monitor_table; @@ -154,7 +156,9 @@ struct hvm_vcpu { =20 struct nestedvcpu nvcpu; =20 +#ifdef CONFIG_ALTP2M struct altp2mvcpu avcpu; +#endif =20 struct mtrr_state mtrr; u64 pat_cr; diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 7375895836..4ed93f3a46 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -889,6 +889,8 @@ void shadow_p2m_init(struct p2m_domain *p2m); void cf_check nestedp2m_write_p2m_entry_post( struct p2m_domain *p2m, unsigned int oflags); =20 +#ifdef CONFIG_ALTP2M + /* * Alternate p2m: shadow p2m tables used for alternate memory views */ @@ -963,13 +965,22 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn= _t gfn, int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int altp2m_i= dx, uint8_t visible); =20 -#ifdef CONFIG_ALTP2M /* Check to see if vcpu should be switched to a different p2m. */ void p2m_altp2m_check(struct vcpu *v, uint16_t idx); -#endif =20 -#else /* !CONFIG_HVM */ +#else /* !CONFIG_ALTP2M */ + struct p2m_domain *p2m_get_altp2m(struct vcpu *v); +bool p2m_set_altp2m(struct vcpu *v, unsigned int idx); +bool p2m_altp2m_get_or_propagate(struct p2m_domain *ap2m, unsigned long gf= n_l, + mfn_t *mfn, p2m_type_t *p2mt, + p2m_access_t *p2ma, unsigned int *page_or= der); +int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn, + mfn_t mfn, unsigned int page_order, + p2m_type_t p2mt, p2m_access_t p2ma); + +#endif /* CONFIG_ALTP2M */ + #endif /* CONFIG_HVM */ =20 /* p2m access to IOMMU flags */ diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index ec5043a8aa..384c24028f 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -494,6 +494,7 @@ int hap_enable(struct domain *d, u32 mode) goto out; } =20 +#ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() ) { /* Init alternate p2m data */ @@ -524,6 +525,7 @@ int hap_enable(struct domain *d, u32 mode) =20 d->arch.altp2m_active =3D false; } +#endif /* CONFIG_ALTP2M */ =20 /* Now let other users see the new mode */ d->arch.paging.mode =3D mode | PG_HAP_enable; @@ -537,9 +539,11 @@ void hap_final_teardown(struct domain *d) { unsigned int i; =20 +#ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() ) for ( i =3D 0; i < MAX_ALTP2M; i++ ) p2m_teardown(d->arch.altp2m_p2m[i], true, NULL); +#endif =20 /* Destroy nestedp2m's first */ for (i =3D 0; i < MAX_NESTEDP2M; i++) { @@ -578,6 +582,7 @@ void hap_teardown(struct domain *d, bool *preempted) for_each_vcpu ( d, v ) hap_vcpu_teardown(v); =20 +#ifdef CONFIG_ALTP2M /* Leave the root pt in case we get further attempts to modify the p2m= . */ if ( hvm_altp2m_supported() ) { @@ -597,6 +602,7 @@ void hap_teardown(struct domain *d, bool *preempted) return; } } +#endif =20 /* Destroy nestedp2m's after altp2m. */ for ( i =3D 0; i < MAX_NESTEDP2M; i++ ) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 21b5b7ecda..0779c41161 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -347,6 +347,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, ui= nt32_t nr, unsigned long gfn_l; long rc =3D 0; =20 +#ifdef CONFIG_ALTP2M /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { @@ -357,6 +358,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, ui= nt32_t nr, =20 ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 if ( !xenmem_access_to_p2m_access(p2m, access, &a) ) return -EINVAL; @@ -403,6 +405,7 @@ long p2m_set_mem_access_multi(struct domain *d, struct p2m_domain *p2m =3D p2m_get_hostp2m(d), *ap2m =3D NULL; long rc =3D 0; =20 +#ifdef CONFIG_ALTP2M /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { @@ -413,6 +416,7 @@ long p2m_set_mem_access_multi(struct domain *d, =20 ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 p2m_lock(p2m); if ( ap2m ) @@ -462,6 +466,7 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xen= mem_access_t *access, { struct p2m_domain *p2m =3D p2m_get_hostp2m(d); =20 +#ifdef CONFIG_ALTP2M if ( !altp2m_active(d) ) { if ( altp2m_idx ) @@ -476,6 +481,7 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xen= mem_access_t *access, =20 p2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 return _p2m_get_mem_access(p2m, gfn, access); } @@ -486,6 +492,7 @@ void arch_p2m_set_access_required(struct domain *d, boo= l access_required) =20 p2m_get_hostp2m(d)->access_required =3D access_required; =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(d) ) { unsigned int i; @@ -497,6 +504,7 @@ void arch_p2m_set_access_required(struct domain *d, boo= l access_required) p2m->access_required =3D access_required; } } +#endif } =20 bool p2m_mem_access_sanity_check(const struct domain *d) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 0cf6818c13..86dc538030 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1297,6 +1297,7 @@ static void ept_set_ad_sync(struct domain *d, bool va= lue) =20 hostp2m->ept.ad =3D value; =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -1315,6 +1316,7 @@ static void ept_set_ad_sync(struct domain *d, bool va= lue) p2m_unlock(p2m); } } +#endif } =20 static void ept_enable_pml(struct p2m_domain *p2m) @@ -1506,6 +1508,7 @@ void __init setup_ept_dump(void) register_keyhandler('D', ept_dump_p2m_table, "dump VT-x EPT tables", 0= ); } =20 +#ifdef CONFIG_ALTP2M void p2m_init_altp2m_ept(struct domain *d, unsigned int i) { struct p2m_domain *p2m =3D array_access_nospec(d->arch.altp2m_p2m, i); @@ -1545,6 +1548,7 @@ unsigned int p2m_find_altp2m_by_eptp(struct domain *d= , uint64_t eptp) altp2m_list_unlock(d); return i; } +#endif /* CONFIG_ALTP2M */ =20 /* * Local variables: diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index b9a7c2dc53..5a3fda903e 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -101,6 +101,7 @@ void p2m_change_entry_type_global(struct domain *d, =20 change_entry_type_global(hostp2m, ot, nt); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -117,6 +118,7 @@ void p2m_change_entry_type_global(struct domain *d, } } } +#endif =20 p2m_unlock(hostp2m); } @@ -145,6 +147,7 @@ bool p2m_memory_type_changed(struct domain *d) =20 _memory_type_changed(hostp2m); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -161,6 +164,7 @@ bool p2m_memory_type_changed(struct domain *d) } } } +#endif =20 p2m_unlock(hostp2m); =20 @@ -930,6 +934,7 @@ void p2m_change_type_range(struct domain *d, =20 change_type_range(hostp2m, start, end, ot, nt); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -946,6 +951,8 @@ void p2m_change_type_range(struct domain *d, } } } +#endif + hostp2m->defer_nested_flush =3D false; if ( nestedhvm_enabled(d) ) p2m_flush_nestedp2m(d); @@ -1003,6 +1010,7 @@ int p2m_finish_type_change(struct domain *d, if ( rc < 0 ) goto out; =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -1022,6 +1030,7 @@ int p2m_finish_type_change(struct domain *d, } } } +#endif =20 out: p2m_unlock(hostp2m); --=20 2.34.1 From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696985; cv=none; d=zohomail.com; s=zohoarc; b=Oc9NRhYSZPXGudQ3JwQ4uDXzEjt920ou11gbn1v7SrWhWDQtantJj7mmcbR/0B14w8n6k1auKQBO37zpxelFeV2Opa6bor7KZkVBo/M499CKOUdMsJ/AxxRqq/j6W78Kmi5ELW8lJaAmsIwWHtSMiHrzd1t5EH0r5P3LTXOiszA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696985; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=utNPBe0Lxwp+qTNxRtXOuoTPyC9W5Wvn2MwpY9okwbY=; b=Gv2J9aaf2kwVbqjJtaCp0F5bhioP4rQjf/EiathZIoz6/DfY62kQLI9FP5fy1JD32mUN14yGOGCoaA4va6W9qQl3FmGhCAfM1c06OAXoAQK4SJssvI2SqEPoFZnkrAjpEkgxs911DZsXFvUjTcg8kaMIYreHpudNReMVEk23/Y8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1752696985798410.0278512177771; Wed, 16 Jul 2025 13:16:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045630.1415831 (Exim 4.92) (envelope-from ) id 1uc8Xr-0005Ne-1j; Wed, 16 Jul 2025 20:16:03 +0000 Received: by outflank-mailman (output) from mailman id 1045630.1415831; Wed, 16 Jul 2025 20:16:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xq-0005MU-Nx; Wed, 16 Jul 2025 20:16:02 +0000 Received: by outflank-mailman (input) for mailman id 1045630; Wed, 16 Jul 2025 20:16:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xo-0003uY-NW for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:16:00 +0000 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [2a00:1450:4864:20::42f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id af6c0d12-6281-11f0-b894-0df219b8e170; Wed, 16 Jul 2025 22:15:58 +0200 (CEST) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3a4e749d7b2so38297f8f.0 for ; Wed, 16 Jul 2025 13:15:58 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: af6c0d12-6281-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696957; x=1753301757; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=utNPBe0Lxwp+qTNxRtXOuoTPyC9W5Wvn2MwpY9okwbY=; b=WCUhLQrt668+Nw5UfqkcD0BXJeFhwXCYo7T2B8zF8MnDwB/25raVWzKAHmtOA/umFW 2zr8caVmx3uAPz02r2L4qR51ndFkI30ovYEoaADPDKLPPOCIgg4rcWhXYke4A2t2ai3f z8jdn80fy6uMaQDcS/v9C5GXTeWnrV5bf8RQqPci8+0sqNRyCGjtL5FWz9d2CVFAQV2t BH3ugYBsSE0T8vK8WfNKY0dRZGa7YaHY6t/3Hj9Nq5iuI172ydkXfGKWMxaBXsDTr5EO L5Boe+y3G3ANZxRGFX6MNfUXEygGn/i/j+gbHoF5VtBFub0og6Nagyscxj0i06HOj7iy jv1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696957; x=1753301757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=utNPBe0Lxwp+qTNxRtXOuoTPyC9W5Wvn2MwpY9okwbY=; b=hIxZAA5Bscimnc5jXAN8IsSl3y1f4kq+ZuIwP1SW7lbHm8EoR/893a19eK/OJjWYwW hk0olUYwqHXBYh+iSf38fuLijBlDJp36Qccq/zFnSag5slXFQqPhNWf+dbqJCFhwd7av Ht/GHSxXd126N+flnu17PJ6lHrV1pzYFNU9ZrivVyXUFz+BS0dS9ZtHHjpvqPSHvXwHK Yvoo0u3pllo/V8lyy/Q40VSLXuofNXuMViX7MOXBMPsmeUsAeKyLeA7lVNjWf9CxxUcB d7Cc3zLALAhpDebT4p2bcMlZEIcaTmRgZiCo3a05zq7Tw++ytYN9uSwv/5/lOpLW+zSC qfyQ== X-Gm-Message-State: AOJu0YzJ5HLcbh67GI1AzejA+qntGM8ArxEP5aLMEZQOHK9PArEM+0KE M5Es7tl5LniTJ5/0e9ehpMu96m8hqHijU4/b9M1trrNJizi4kM5UACIbj/iVgg== X-Gm-Gg: ASbGncvkEXrjrPgaD9af7wsw3AdCp6xpfbtwD+WBbTFIgXShvyV1jnz79LHAC1Ni/+s 0vZZ7neFYSSM7IRRic08l21hBvKzR9CgTm9sBWRjZpZeKiLWYuz95egDBiZP/AubtQSzinpP/3f 8lvwTJgiQmmcNP6HnO76dFC0B9OAHhgsjjfjNyREqU7+V/jQBX3tJv9ZM/kfdV5K5raWbF2n5Ks W3XMtOocA1J3eCNzSwv5lRd1pVpUfHkX5W1rppLwTFPMsB8Y87fPXfTLq/ELSvXfkf78F2UdCh9 TLgzGVG8Z9lKaU7IuIMYPwAuie912ah95vRvOLvA4Od9rEnTNXL4C4fxpm4L05PvVvRWbYKEu7S 24LS7OkbmpeQGOKV64Ch54sp8D4nb1xg+gC8K1FlVy5w+J4nzFS1/DPDjhl9BB5sSEiR54GBl2D zMdBYCJZ/LIvhYC2cGIf8STw== X-Google-Smtp-Source: AGHT+IGV+BnPEQ0eZau/1SdrCzN7AxvgpY+osZaSpQC+Pl6tRh/fVHDVVUrxIYol+3O4ULAQAmxclw== X-Received: by 2002:a05:6000:25c4:b0:3b5:f908:2374 with SMTP id ffacd0b85a97d-3b60dd15becmr1493124f8f.0.1752696957035; Wed, 16 Jul 2025 13:15:57 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu Subject: [PATCH v10 6/9] xen: Make the maximum number of altp2m views configurable for x86 Date: Wed, 16 Jul 2025 20:15:36 +0000 Message-Id: <2c43671a77ebe71f58cd0815000d356f85df781d.1752691429.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696987322116600 From: Petr Bene=C5=A1 This commit introduces the ability to configure the maximum number of altp2m views for the domain during its creation. Previously, the limits were hardc= oded to a maximum of 10. This change allows for greater flexibility in environme= nts that require more or fewer altp2m views. The maximum configurable limit for nr_altp2m on x86 is now set to MAX_NR_ALTP2M (which currently holds the MAX_EPTP value - 512). This cap is linked to the architectural limit of the EPTP-switching VMFUNC, which suppo= rts up to 512 entries. Despite there being no inherent need for limiting nr_alt= p2m in scenarios not utilizing VMFUNC, decoupling these components would necess= itate substantial code changes. xen_domctl_createdomain::altp2m is extended for a new field `nr`, that will configure this limit for a domain. Additionally, previous altp2m.opts value has been reduced from uint32_t to uint16_t so that both of these fields occ= upy as little space as possible. Accesses to the altp2m_p2m array are modified to respect the new nr_altp2m value. Accesses to the altp2m_(visible_)eptp arrays are unmodified, since these arrays always have fixed size of MAX_EPTP. Additional sanitization is introduced in the x86/arch_sanitise_domain_config to fix the altp2m.nr value to 10 if it is previously set to 0. This behavior is only temporary and immediately removed in the upcoming commit (which will disallow creating a domain with enabled altp2m with zero nr_altp2m). The reason for this temporary workaround is to retain the legacy behavior until the feature is fully activated in libxl. Also, arm/arch_sanitise_domain_config is extended to not allow requesting non-zero altp2ms. Signed-off-by: Petr Bene=C5=A1 Acked-by: Jan Beulich --- xen/arch/arm/domain.c | 2 +- xen/arch/x86/domain.c | 40 ++++++++++++++--- xen/arch/x86/hvm/hvm.c | 8 +++- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/include/asm/altp2m.h | 28 ++++++++++-- xen/arch/x86/include/asm/domain.h | 9 ++-- xen/arch/x86/include/asm/p2m.h | 4 +- xen/arch/x86/mm/altp2m.c | 72 ++++++++++++++++--------------- xen/arch/x86/mm/hap/hap.c | 6 +-- xen/arch/x86/mm/mem_access.c | 22 ++++------ xen/arch/x86/mm/mem_sharing.c | 4 +- xen/arch/x86/mm/p2m-ept.c | 7 +-- xen/arch/x86/mm/p2m-pt.c | 2 + xen/arch/x86/mm/p2m.c | 8 ++-- xen/common/domain.c | 6 +++ xen/include/public/domctl.h | 5 ++- xen/include/xen/sched.h | 4 ++ 17 files changed, 151 insertions(+), 78 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 79a144e61b..9a4f72c62b 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -693,7 +693,7 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) return -EINVAL; } =20 - if ( config->altp2m.opts ) + if ( config->altp2m.opts || config->altp2m.nr ) { dprintk(XENLOG_INFO, "Altp2m not supported\n"); return -EINVAL; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 56c3816187..155ea1f79f 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -716,16 +716,42 @@ int arch_sanitise_domain_config(struct xen_domctl_cre= atedomain *config) return -EINVAL; } =20 - if ( altp2m_mode && nested_virt ) + if ( altp2m_mode ) { - dprintk(XENLOG_INFO, - "Nested virt and altp2m are not supported together\n"); - return -EINVAL; - } + if ( !hvm_altp2m_supported() ) + { + dprintk(XENLOG_INFO, "altp2m is not supported\n"); + return -EINVAL; + } + + if ( !hap ) + { + dprintk(XENLOG_INFO, "altp2m is only supported with HAP\n"); + return -EINVAL; + } + + if ( nested_virt ) + { + dprintk(XENLOG_INFO, + "Nested virt and altp2m are not supported together\n"); + return -EINVAL; + } + + if ( !config->altp2m.nr ) + { + /* Fix the value to the legacy default */ + config->altp2m.nr =3D 10; + } =20 - if ( altp2m_mode && !hap ) + if ( config->altp2m.nr > MAX_NR_ALTP2M ) + { + dprintk(XENLOG_INFO, "altp2m.nr must be <=3D %lu\n", MAX_NR_AL= TP2M); + return -EINVAL; + } + } + else if ( config->altp2m.nr ) { - dprintk(XENLOG_INFO, "altp2m is only supported with HAP\n"); + dprintk(XENLOG_INFO, "altp2m.nr must be zero when altp2m is off\n"= ); return -EINVAL; } =20 diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 5183bfea3a..e16850d1f8 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4675,6 +4675,12 @@ static int do_altp2m_op( goto out; } =20 + if ( d->nr_altp2m =3D=3D 0 ) + { + rc =3D -EINVAL; + goto out; + } + if ( (rc =3D xsm_hvm_altp2mhvm_op(XSM_OTHER, d, mode, a.cmd)) ) goto out; =20 @@ -5275,7 +5281,7 @@ void hvm_fast_singlestep(struct vcpu *v, uint16_t p2m= idx) if ( !hvm_is_singlestep_supported() ) return; =20 - if ( p2midx >=3D MAX_ALTP2M ) + if ( p2midx >=3D v->domain->nr_altp2m ) return; =20 v->arch.hvm.single_step =3D true; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b136d89546..0743177933 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -4974,7 +4974,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_u= ser_regs *regs) { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; ++i ) + for ( i =3D 0; i < currd->nr_altp2m; ++i ) { if ( currd->arch.altp2m_eptp[i] =3D=3D mfn_x(INVALID_MFN) ) continue; diff --git a/xen/arch/x86/include/asm/altp2m.h b/xen/arch/x86/include/asm/a= ltp2m.h index c57a8c5588..8ecd74f363 100644 --- a/xen/arch/x86/include/asm/altp2m.h +++ b/xen/arch/x86/include/asm/altp2m.h @@ -13,12 +13,32 @@ #include /* for struct vcpu, struct domain */ #include /* for vcpu_altp2m */ =20 +static inline bool altp2m_is_eptp_valid(const struct domain *d, + unsigned int idx) +{ + /* There must be enough EPTP entries to cover all altp2m indices */ + BUILD_BUG_ON(MAX_EPTP < MAX_NR_ALTP2M); + + /* Domain should not have more altp2m entries than MAX_NR_ALTP2M */ + ASSERT(d->nr_altp2m <=3D MAX_NR_ALTP2M); + + /* EPTP index is used as altp2m index */ + return idx < d->nr_altp2m && + d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] !=3D + mfn_x(INVALID_MFN); +} + /* Alternate p2m HVM on/off per domain */ static inline bool altp2m_active(const struct domain *d) { return d->arch.altp2m_active; } =20 +static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v) +{ + return vcpu_altp2m(v).p2midx; +} + /* Alternate p2m VCPU */ void altp2m_vcpu_initialise(struct vcpu *v); void altp2m_vcpu_destroy(struct vcpu *v); @@ -26,11 +46,13 @@ void altp2m_vcpu_destroy(struct vcpu *v); int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn); void altp2m_vcpu_disable_ve(struct vcpu *v); =20 -static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v) +#else + +static inline bool altp2m_is_eptp_valid(const struct domain *d, + unsigned int idx) { - return vcpu_altp2m(v).p2midx; + return false; } -#else =20 static inline bool altp2m_active(const struct domain *d) { diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index 8749c5eba0..02a00e1c07 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -258,11 +258,12 @@ struct paging_vcpu { struct shadow_vcpu shadow; }; =20 -#define MAX_NESTEDP2M 10 +#define MAX_EPTP (PAGE_SIZE / sizeof(uint64_t)) +#define MAX_NR_ALTP2M MAX_EPTP +#define MAX_NESTEDP2M 10 =20 -#define MAX_ALTP2M 10 /* arbitrary */ #define INVALID_ALTP2M 0xffff -#define MAX_EPTP (PAGE_SIZE / sizeof(uint64_t)) + struct p2m_domain; struct time_scale { int shift; @@ -354,7 +355,7 @@ struct arch_domain #ifdef CONFIG_ALTP2M /* altp2m: allow multiple copies of host p2m */ bool altp2m_active; - struct p2m_domain *altp2m_p2m[MAX_ALTP2M]; + struct p2m_domain **altp2m_p2m; mm_lock_t altp2m_list_lock; uint64_t *altp2m_eptp; uint64_t *altp2m_visible_eptp; diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 4ed93f3a46..738654590a 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -903,7 +903,7 @@ static inline struct p2m_domain *p2m_get_altp2m(struct = vcpu *v) if ( index =3D=3D INVALID_ALTP2M ) return NULL; =20 - BUG_ON(index >=3D MAX_ALTP2M); + BUG_ON(index >=3D v->domain->nr_altp2m); =20 return v->domain->arch.altp2m_p2m[index]; } @@ -913,7 +913,7 @@ static inline bool p2m_set_altp2m(struct vcpu *v, unsig= ned int idx) { struct p2m_domain *orig; =20 - BUG_ON(idx >=3D MAX_ALTP2M); + BUG_ON(idx >=3D v->domain->nr_altp2m); =20 if ( idx =3D=3D vcpu_altp2m(v).p2midx ) return false; diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c index 6fe1e9ed6b..0261360aae 100644 --- a/xen/arch/x86/mm/altp2m.c +++ b/xen/arch/x86/mm/altp2m.c @@ -9,12 +9,16 @@ #include #include #include +#include #include "mm-locks.h" #include "p2m.h" =20 void altp2m_vcpu_initialise(struct vcpu *v) { + if ( !v->domain->nr_altp2m ) + return; + if ( v !=3D current ) vcpu_pause(v); =20 @@ -32,6 +36,9 @@ altp2m_vcpu_destroy(struct vcpu *v) { struct p2m_domain *p2m; =20 + if ( !v->domain->nr_altp2m ) + return; + if ( v !=3D current ) vcpu_pause(v); =20 @@ -122,7 +129,12 @@ int p2m_init_altp2m(struct domain *d) struct p2m_domain *hostp2m =3D p2m_get_hostp2m(d); =20 mm_lock_init(&d->arch.altp2m_list_lock); - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + d->arch.altp2m_p2m =3D xvzalloc_array(struct p2m_domain *, d->nr_altp2= m); + + if ( !d->arch.altp2m_p2m ) + return -ENOMEM; + + for ( i =3D 0; i < d->nr_altp2m; i++ ) { d->arch.altp2m_p2m[i] =3D p2m =3D p2m_init_one(d); if ( p2m =3D=3D NULL ) @@ -143,7 +155,7 @@ void p2m_teardown_altp2m(struct domain *d) unsigned int i; struct p2m_domain *p2m; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( !d->arch.altp2m_p2m[i] ) continue; @@ -151,6 +163,8 @@ void p2m_teardown_altp2m(struct domain *d) d->arch.altp2m_p2m[i] =3D NULL; p2m_free_one(p2m); } + + XVFREE(d->arch.altp2m_p2m); } =20 int altp2m_get_effective_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *= mfn, @@ -200,7 +214,7 @@ bool p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsig= ned int idx) struct domain *d =3D v->domain; bool rc =3D false; =20 - if ( idx >=3D MAX_ALTP2M ) + if ( idx >=3D d->nr_altp2m ) return rc; =20 altp2m_list_lock(d); @@ -306,8 +320,8 @@ static void p2m_reset_altp2m(struct domain *d, unsigned= int idx, { struct p2m_domain *p2m; =20 - ASSERT(idx < MAX_ALTP2M); - p2m =3D array_access_nospec(d->arch.altp2m_p2m, idx); + ASSERT(idx < d->nr_altp2m); + p2m =3D d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; =20 p2m_lock(p2m); =20 @@ -332,7 +346,7 @@ void p2m_flush_altp2m(struct domain *d) =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { p2m_reset_altp2m(d, i, ALTP2M_DEACTIVATE); d->arch.altp2m_eptp[i] =3D mfn_x(INVALID_MFN); @@ -348,9 +362,9 @@ static int p2m_activate_altp2m(struct domain *d, unsign= ed int idx, struct p2m_domain *hostp2m, *p2m; int rc; =20 - ASSERT(idx < MAX_ALTP2M); + ASSERT(idx < d->nr_altp2m); =20 - p2m =3D array_access_nospec(d->arch.altp2m_p2m, idx); + p2m =3D d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; hostp2m =3D p2m_get_hostp2m(d); =20 p2m_lock(p2m); @@ -388,7 +402,7 @@ int p2m_init_altp2m_by_id(struct domain *d, unsigned in= t idx) int rc =3D -EINVAL; struct p2m_domain *hostp2m =3D p2m_get_hostp2m(d); =20 - if ( idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) + if ( idx >=3D d->nr_altp2m ) return rc; =20 altp2m_list_lock(d); @@ -415,7 +429,7 @@ int p2m_init_next_altp2m(struct domain *d, uint16_t *id= x, =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) continue; @@ -437,7 +451,7 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned= int idx) struct p2m_domain *p2m; int rc =3D -EBUSY; =20 - if ( !idx || idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) + if ( !idx || idx >=3D d->nr_altp2m ) return rc; =20 rc =3D domain_pause_except_self(d); @@ -450,7 +464,7 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned= int idx) if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] !=3D mfn_x(INVALID_MFN) ) { - p2m =3D array_access_nospec(d->arch.altp2m_p2m, idx); + p2m =3D d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; =20 if ( !_atomic_read(p2m->active_vcpus) ) { @@ -475,7 +489,7 @@ int p2m_switch_domain_altp2m_by_id(struct domain *d, un= signed int idx) struct vcpu *v; int rc =3D -EINVAL; =20 - if ( idx >=3D MAX_ALTP2M ) + if ( idx >=3D d->nr_altp2m ) return rc; =20 rc =3D domain_pause_except_self(d); @@ -510,13 +524,11 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned = int idx, mfn_t mfn; int rc =3D -EINVAL; =20 - if ( idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, idx) ) return rc; =20 hp2m =3D p2m_get_hostp2m(d); - ap2m =3D array_access_nospec(d->arch.altp2m_p2m, idx); + ap2m =3D d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; =20 p2m_lock(hp2m); p2m_lock(ap2m); @@ -572,7 +584,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t= gfn, =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { p2m_type_t t; p2m_access_t a; @@ -595,7 +607,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t= gfn, else { /* At least 2 altp2m's impacted, so reset everything */ - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( i =3D=3D last_reset_idx || d->arch.altp2m_eptp[i] =3D=3D mfn_x(INVALID_MFN) ) @@ -659,12 +671,11 @@ int p2m_set_suppress_ve_multi(struct domain *d, =20 if ( sve->view > 0 ) { - if ( sve->view >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) = || - d->arch.altp2m_eptp[array_index_nospec(sve->view, MAX_EPTP)] = =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, sve->view) ) return -EINVAL; =20 - p2m =3D ap2m =3D array_access_nospec(d->arch.altp2m_p2m, sve->view= ); + p2m =3D ap2m =3D + d->arch.altp2m_p2m[array_index_nospec(sve->view, d->nr_altp2m)= ]; } =20 p2m_lock(host_p2m); @@ -727,12 +738,11 @@ int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, = bool *suppress_ve, =20 if ( altp2m_idx > 0 ) { - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP)= || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]= =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) return -EINVAL; =20 - p2m =3D ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_id= x); + p2m =3D ap2m =3D + d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m= )]; } else p2m =3D host_p2m; @@ -761,13 +771,7 @@ int p2m_set_altp2m_view_visibility(struct domain *d, u= nsigned int altp2m_idx, =20 altp2m_list_lock(d); =20 - /* - * Eptp index is correlated with altp2m index and should not exceed - * min(MAX_ALTP2M, MAX_EPTP). - */ - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] =3D= =3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) rc =3D -EINVAL; else if ( visible ) d->arch.altp2m_visible_eptp[array_index_nospec(altp2m_idx, MAX_EPT= P)] =3D diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index 384c24028f..4aec98109d 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -516,7 +516,7 @@ int hap_enable(struct domain *d, u32 mode) d->arch.altp2m_visible_eptp[i] =3D mfn_x(INVALID_MFN); } =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { rv =3D p2m_alloc_table(d->arch.altp2m_p2m[i]); if ( rv !=3D 0 ) @@ -541,7 +541,7 @@ void hap_final_teardown(struct domain *d) =20 #ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() ) - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) p2m_teardown(d->arch.altp2m_p2m[i], true, NULL); #endif =20 @@ -595,7 +595,7 @@ void hap_teardown(struct domain *d, bool *preempted) FREE_XENHEAP_PAGE(d->arch.altp2m_eptp); FREE_XENHEAP_PAGE(d->arch.altp2m_visible_eptp); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { p2m_teardown(d->arch.altp2m_p2m[i], false, preempted); if ( preempted && *preempted ) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 0779c41161..4538a63668 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -81,6 +81,7 @@ bool p2m_mem_access_emulate_check(struct vcpu *v, =20 if ( altp2m_active(d) ) p2m =3D p2m_get_altp2m(v); + if ( !p2m ) p2m =3D p2m_get_hostp2m(d); =20 @@ -145,6 +146,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gl= a, =20 if ( altp2m_active(d) ) p2m =3D p2m_get_altp2m(v); + if ( !p2m ) p2m =3D p2m_get_hostp2m(d); =20 @@ -351,12 +353,10 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, = uint32_t nr, /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP)= || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]= =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) return -EINVAL; =20 - ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + ap2m =3D d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_a= ltp2m)]; } #endif =20 @@ -409,12 +409,10 @@ long p2m_set_mem_access_multi(struct domain *d, /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP)= || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]= =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) return -EINVAL; =20 - ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + ap2m =3D d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_a= ltp2m)]; } #endif =20 @@ -474,12 +472,10 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, x= enmem_access_t *access, } else if ( altp2m_idx ) /* altp2m view 0 is treated as the hostp2m */ { - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP)= || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]= =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) return -EINVAL; =20 - p2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + p2m =3D d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_al= tp2m)]; } #endif =20 @@ -496,7 +492,7 @@ void arch_p2m_set_access_required(struct domain *d, boo= l access_required) if ( altp2m_active(d) ) { unsigned int i; - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { struct p2m_domain *p2m =3D d->arch.altp2m_p2m[i]; =20 diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index da28266ef0..4787b27964 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -901,6 +901,7 @@ static int nominate_page(struct domain *d, gfn_t gfn, if ( !page || is_special_page(page) ) goto out; =20 +#ifdef CONFIG_ALTP2M /* Check if there are mem_access/remapped altp2m entries for this page= */ if ( altp2m_active(d) ) { @@ -912,7 +913,7 @@ static int nominate_page(struct domain *d, gfn_t gfn, =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { ap2m =3D d->arch.altp2m_p2m[i]; if ( !ap2m ) @@ -929,6 +930,7 @@ static int nominate_page(struct domain *d, gfn_t gfn, =20 altp2m_list_unlock(d); } +#endif /* CONFIG_ALTP2M */ =20 /* Try to convert the mfn to the sharable type */ ret =3D page_make_sharable(d, page, expected_refcnt, validate_only); diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 86dc538030..1c48e876fb 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1302,7 +1302,7 @@ static void ept_set_ad_sync(struct domain *d, bool va= lue) { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { struct p2m_domain *p2m; =20 @@ -1511,7 +1511,8 @@ void __init setup_ept_dump(void) #ifdef CONFIG_ALTP2M void p2m_init_altp2m_ept(struct domain *d, unsigned int i) { - struct p2m_domain *p2m =3D array_access_nospec(d->arch.altp2m_p2m, i); + struct p2m_domain *p2m =3D + d->arch.altp2m_p2m[array_index_nospec(i, d->nr_altp2m)]; struct p2m_domain *hostp2m =3D p2m_get_hostp2m(d); struct ept_data *ept; =20 @@ -1530,7 +1531,7 @@ unsigned int p2m_find_altp2m_by_eptp(struct domain *d= , uint64_t eptp) =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] =3D=3D mfn_x(INVALID_MFN) ) continue; diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 666abd46be..5a6ce2f8bc 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -519,12 +519,14 @@ int p2m_pt_handle_deferred_changes(uint64_t gpa) struct p2m_domain *p2m =3D p2m_get_hostp2m(current->domain); int rc; =20 +#ifdef CONFIG_ALTP2M /* * Should altp2m ever be enabled for NPT / shadow use, this code * should be updated to make use of the active altp2m, like * ept_handle_misconfig(). */ ASSERT(!altp2m_active(current->domain)); +#endif =20 p2m_lock(p2m); rc =3D do_recalc(p2m, PFN_DOWN(gpa)); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 5a3fda903e..e802f2e4e6 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -106,7 +106,7 @@ void p2m_change_entry_type_global(struct domain *d, { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) { @@ -152,7 +152,7 @@ bool p2m_memory_type_changed(struct domain *d) { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) { @@ -939,7 +939,7 @@ void p2m_change_type_range(struct domain *d, { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) { @@ -1015,7 +1015,7 @@ int p2m_finish_type_change(struct domain *d, { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) { diff --git a/xen/common/domain.c b/xen/common/domain.c index 303c338ef2..b7c58e8e2b 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -811,6 +811,12 @@ struct domain *domain_create(domid_t domid, if ( config ) { d->options =3D config->flags; +#ifdef CONFIG_ALTP2M + d->nr_altp2m =3D config->altp2m.nr; +#else + ASSERT(!config->altp2m.nr); +#endif + d->vmtrace_size =3D config->vmtrace_size; } =20 diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a69dd96084..573d34f239 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -116,7 +116,10 @@ struct xen_domctl_createdomain { /* Altp2m mode signaling uses bits [0, 1]. */ #define XEN_DOMCTL_ALTP2M_mode_mask (0x3U) #define XEN_DOMCTL_ALTP2M_mode(m) ((m) & XEN_DOMCTL_ALTP2M_mode_mask) - uint32_t opts; + uint16_t opts; + + /* Number of altp2ms to permit. */ + uint16_t nr; } altp2m; =20 /* Per-vCPU buffer size in bytes. 0 to disable. */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index fe53d4fab7..e46d10c0c3 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -619,6 +619,10 @@ struct domain unsigned int guest_request_sync : 1; } monitor; =20 +#ifdef CONFIG_ALTP2M + unsigned int nr_altp2m; /* Number of altp2m tables. */ +#endif + unsigned int vmtrace_size; /* Buffer size in bytes, or 0 to disable. */ =20 #ifdef CONFIG_ARGO --=20 2.34.1 From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696987; cv=none; d=zohomail.com; s=zohoarc; b=Rfd7L0hultJGRygjR9+Ah2w22gP6yInpAtrWLRkrKkqcuwtkDydJNz7kHqxtHA/qR5a8pfjG5RbZnoY/kaZbYPIi38ze8I3NVkkvSIvIn8d31RO37ljcTdLyEx3JK7J4LhzL/4vaUnrDNSp0s1eKWZfWNdAgFLhpJt7xZ/Gs8l0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696987; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pb/Ky+NjHb2U/AUnw3rA7qjcFJaFaS7qOBSec9pqZjI=; b=f7sBOeU1HhQGqE6p7d5IqMp03HDXJYgGD+bB17OoK+mNAetv8oxqdQ5Gl1PEK1kFnRsZmJMcHtPsU5mD/iDqFD41yZl+xh1z+9v/LuJSY0XDQiqwe/NodGhTrcoGFayz9yjgqtvcMNkhw3jPTjQtkpyUfFmnLoUZbRsBeF81dqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17526969871351013.5874164153278; Wed, 16 Jul 2025 13:16:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045629.1415824 (Exim 4.92) (envelope-from ) id 1uc8Xq-0005KX-IW; Wed, 16 Jul 2025 20:16:02 +0000 Received: by outflank-mailman (output) from mailman id 1045629.1415824; Wed, 16 Jul 2025 20:16:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xq-0005KQ-Es; Wed, 16 Jul 2025 20:16:02 +0000 Received: by outflank-mailman (input) for mailman id 1045629; Wed, 16 Jul 2025 20:16:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xo-0003uY-C1 for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:16:00 +0000 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [2a00:1450:4864:20::32a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id afaf6f95-6281-11f0-b894-0df219b8e170; Wed, 16 Jul 2025 22:15:58 +0200 (CEST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-456133b8d47so293335e9.2 for ; Wed, 16 Jul 2025 13:15:58 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: afaf6f95-6281-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696958; x=1753301758; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pb/Ky+NjHb2U/AUnw3rA7qjcFJaFaS7qOBSec9pqZjI=; b=a1EMwdoHAatuFBiKj4D5g+KXzKZqwlrUKjtwKlOcAc0Y4pqRcCaZS5yRGe2+cxn3oW qdL10KMbPAbvCrB5q+BRYjO4FZR7vEbxpHuj4D/GpApgLqKCBLdb2BsddM9hdj+VsHDR 1Zzy8t+EOKd+g5e1I9PCiHdmZI4SejwCoSLm0K1SwPScFO+j+gF2905+L2knRFDbBXNU /AKeLFMK3k/JOE3bosyyv9tFQhUsrpofI+yRaf5lqIlQzWt9GLv2pCQSuHVyF0Nsx3BN XcuMoQryVSAmiTEzJuimpCYYcKHEli4mi+JRMVHkURbEuKhUqhSUehh8ps0k5bX1E3t2 h65w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696958; x=1753301758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pb/Ky+NjHb2U/AUnw3rA7qjcFJaFaS7qOBSec9pqZjI=; b=rWWo2+amWO+JB1erQcIKQnRmbszzdcs9/AswASaDWCoIZWfA9g95RV4zC4MZ0pZmqd FbjUG7n4ZVSS+ko9lBS87Eq/lfHKMLqRdg8LxXLSECVvhskyIVC7N8O2rSoDHDbWMpNd onJCVUaKkYEiRhiG0lBk2+r9xYMwjz1B8FKMYX8HwyQsLOcZiom8aH4nBF6ZZi4MoG6L +el7XxoAejDglB1anrO1NoAUxjIhrZ7X/TauC9pGx2MoK21CQI5nlhNRqp4584qWjAgz PhxWhxb/zyzypR2IxJ/+5wPiNTCc6cKg+A+tDmHeuFHf9GKqQBDgeX92UeH88SIzj4Uq S38w== X-Gm-Message-State: AOJu0Yw42lMkoRQIQaOOjz2x5iWU0y6TKlSlgJlpmLvD0DSeCf7sVi3z HvXysE2pStSXdVmAAOkh7MZzPvuf6V4f52NRJaao1Z6KXyvsW8P3v6/lCGtLcA== X-Gm-Gg: ASbGncthlaTQiUmK+Ec7GfHfHQyyVu6mXIUeZrv+4Y7qWs+1r378V4+oMHIRH4HGcz3 ISts+4FBPI7huURbYocxxTLzFsu5udVgzsvmXhtztxqeJk5IOSJWM0Zav99BDLQ/3CiB5g9AFMj Kjee+XOcVeB/YvzbZ92J8e/CLPMOxrVcAX59IQLGa0tSBnPo4JUsbcHCOAiXp2fXIUB0uF1NPMp Bfxn5Vus6+Xu8sr4XVXz7SR+k1Y5BWewhYHxPWswRkKxBErxXr3MPDZbowbcLkPf45q4MO0YVZ/ BfxDUDXCtQQvReCsd5Bk6KCpqbLvTcpz2usGLrrWqZNwJvS6kmW4aKTbLpn8cfGl3ID0MZYyioY OD8HOljYcEnTCnP3R4dSDk9xyJ6z8y5zNIGNTnVDaagJ6fL7hZh8ESeoB3441dPEb4ydVaeULuC BG+1wg1FiC/bRf8HVtI524kA== X-Google-Smtp-Source: AGHT+IEfxkXPaUlJQ1FGYw3ZFlPlmW8mFDKhMmmFN93dQupLAdmdCphaPymKJ4IVQZgU4shr5ysPug== X-Received: by 2002:a05:6000:2a02:b0:3a4:e193:e6e7 with SMTP id ffacd0b85a97d-3b60dd60e9dmr1267286f8f.5.1752696957817; Wed, 16 Jul 2025 13:15:57 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Anthony PERARD , Juergen Gross Subject: [PATCH v10 7/9] tools/libxl: Activate the altp2m_count feature Date: Wed, 16 Jul 2025 20:15:37 +0000 Message-Id: <1fcbc199c3e60d6d62271b6807c395e82724ba56.1752691429.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696989141116600 From: Petr Bene=C5=A1 This commit activates the previously introduced altp2m_count parameter, establishing the connection between libxl and Xen. Signed-off-by: Petr Bene=C5=A1 Acked-by: Anthony PERARD --- tools/libs/light/libxl_create.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index 4301f17f90..a796178050 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -596,6 +596,10 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_con= fig *d_config, .max_grant_frames =3D b_info->max_grant_frames, .max_maptrack_frames =3D b_info->max_maptrack_frames, .grant_opts =3D XEN_DOMCTL_GRANT_version(b_info->max_grant_ver= sion), + .altp2m =3D { + .opts =3D 0, /* .opts will be set below */ + .nr =3D b_info->altp2m_count, + }, .vmtrace_size =3D ROUNDUP(b_info->vmtrace_buf_kb << 10, XC_PAG= E_SHIFT), .cpupool_id =3D info->poolid, }; --=20 2.34.1 From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696983; cv=none; d=zohomail.com; s=zohoarc; b=fLX2Uod1QSbRduOXzNeyUjx4hwYE6hvFiduaOTsMkBaNSsdBYmTdTnNrKoUbOmdgIrwujAHAzxNx1VGVnlbiluNcVJtU2hDvNlKEzjClofALv4j7Ec7lfoLGcqNXgs5D9OWjkX+z7D8Rp0a9CYn7beTVipsgFb9kiGuvPdo0/1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696983; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PYagUw7+nV4AIrSjbYjtskD6tyaobfXIr4xaV+yxYuw=; b=R15E5pu1akeablEcHRp+XuI+8KF+xY1ex5Ql3OuL+9g7iexk9Vz4kYrpyjtMldwCK7AE8IxSoFMYgnnWrpZpqcY7KG0fkAjdIPqwD+dOeKhXBw3QW3b1BWGM+CE7YeoPZTMyW8vSnkwRQtuaDQHnzdy4ZBrdpV5XatjhhjkAIO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17526969839881010.6981567566246; Wed, 16 Jul 2025 13:16:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045631.1415838 (Exim 4.92) (envelope-from ) id 1uc8Xr-0005Xz-O1; Wed, 16 Jul 2025 20:16:03 +0000 Received: by outflank-mailman (output) from mailman id 1045631.1415838; Wed, 16 Jul 2025 20:16:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xr-0005Vw-BS; Wed, 16 Jul 2025 20:16:03 +0000 Received: by outflank-mailman (input) for mailman id 1045631; Wed, 16 Jul 2025 20:16:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xp-0003uY-Na for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:16:01 +0000 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [2a00:1450:4864:20::42c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b03d1ae7-6281-11f0-b894-0df219b8e170; Wed, 16 Jul 2025 22:15:59 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3b39c46e1cfso32364f8f.3 for ; Wed, 16 Jul 2025 13:15:59 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:58 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b03d1ae7-6281-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696959; x=1753301759; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PYagUw7+nV4AIrSjbYjtskD6tyaobfXIr4xaV+yxYuw=; b=cOYLvQR4xMMllxQSoMXCLXeUYzhuM/qj0NkOLUbLXAmu6OxYc9YysBqVPJzLqohCEp CASFIvm0GwTIO2D7LK8bgAVeE8vsQ8Y3YkquRB5bYbMqcIOfq7SYw7mjw9tOUvnAjhsB shr6b1GO6t7J1xfXpY//5JmyW0nsspBEcKFZ/xRUv1wy7TEsFrR7ubRkGTX7JR0LZ9XU FggMzjWD8O14Lu2mcYCJQMxuWyF0knAiIH7uEbIE7JhpVxpdknJGGW26KdOiEIDpS7Gi Mm/R1jDg71DUP2gDpcJA5W3vGPDdtCmF1fYZraogMO5fYSuymLqR7lRMcEXPX/9VyOaf SRVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696959; x=1753301759; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PYagUw7+nV4AIrSjbYjtskD6tyaobfXIr4xaV+yxYuw=; b=KvKNwxW63spq8xAgy84xI8G98KJWWZvhPwPASPssNZUfGTrHQ/RD4LSGQuFFOPh493 hBsePW5tH8VKB0yMmKdKJqURvKOmS4vzb81JIzJAjLZ4ISPdYDc06BVLoLyCS7iRfzi9 RWrFFMjv0m/zUEyx8HkwVe6oYpcaJhnWa0xXw5BbtLrQgk0oFzmhpigSQHDGPZVmuy6l D+83fjWgnR8XrP0FC5d9ZEE/fWYcdXWqIXcuoZcC8USnf4W9lSNq+AkABSmBg9aTrxem 1avyldwTQYpSt4fTu/WlBCA1A7oaJhsBfSq24m3nC2cJD8w+PHTo+wW3S9jEqZtjT/F0 8GKA== X-Gm-Message-State: AOJu0Yxqq7Dt6lsNSEiZ2VRBA7pSRO09Ql1WFhCXg0raQ4omUEZBCnLS NFdPY/cMsQIpK3eYoHtR/3ba5jBKr3QI/9v7JLXhVmsyPwn0/DAwiWmz2hUAsg== X-Gm-Gg: ASbGnctaVuQeoTPVZFD/6lkvQcNCqtmG0x3tUX/5aZj3BbHtEh1SkNyG8YSRsidel95 xq9Ph4FN2DPU/HTjjX1SACakSnlac2DEdQQBO9pMqE7wcSgZr7qUHvEIJk8G0VgkbK8weotI+Fe U9ML21JMAOPuUccj7kTbakivdViLwBp+xbQPF7gOWGRJ6sCKc3GT3orHkZY8ttJ02FCDyD2oVUn SkjN+vIxKzUu6Wnbeq4VzBw+gpKnl7Y0FT4xGaFstc8YjEYFMrTaEl3L+AJpcyMc4Q3cu/U3YnL Ot7GAlB5ecPaNmkiZaFF6Qcz0XfsQxp1btzpfXVp3lMedxTzwO7l88KyVqrnMozWAwRDpQ6SC2I g0boKLJzCDh+tfhxUBhgLpS1vWQC1/rtZuxqCwW2kRu0O1kqxn8d5OwS08OjZJaLDn4PehqADLK Vegrz0UZXTEsD5CcVZnWRw5g== X-Google-Smtp-Source: AGHT+IH7GdGusUGVrk9HqTrDwfvIuKdblYUlr4EsEkYGvF6IYaWxoum2v+okSPRztKqsgEEcfS+Xog== X-Received: by 2002:a05:600c:a30b:b0:453:78fd:1769 with SMTP id 5b1f17b1804b1-4562e279874mr12804105e9.4.1752696958714; Wed, 16 Jul 2025 13:15:58 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v10 8/9] xen/x86: Disallow creating domains with altp2m enabled and altp2m.nr == 0 Date: Wed, 16 Jul 2025 20:15:38 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696985059116600 From: Petr Bene=C5=A1 Since libxl finally sends the altp2m.nr value, we can remove the previously introduced temporary workaround. Creating domain with enabled altp2m while setting altp2m.nr =3D=3D 0 doesn't make sense and it's probably not what user wants. Signed-off-by: Petr Bene=C5=A1 Acked-by: Jan Beulich --- xen/arch/x86/domain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 155ea1f79f..872e97999c 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -739,8 +739,9 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) =20 if ( !config->altp2m.nr ) { - /* Fix the value to the legacy default */ - config->altp2m.nr =3D 10; + dprintk(XENLOG_INFO, + "altp2m must be requested with altp2m.nr > 0\n"); + return -EINVAL; } =20 if ( config->altp2m.nr > MAX_NR_ALTP2M ) --=20 2.34.1 From nobody Thu Oct 30 22:46:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696984; cv=none; d=zohomail.com; s=zohoarc; b=JwOCcpCPXHJmvHH+IotlXUuaclKlIWOj5OongvpHIpBWaGsXvo0faZGkw4YaCfLhUVzAHMVwHW3hC8tbrYi6gksPSpmOScKM44IZWsY+l9EC2Cgkn4FvAmGOPxaKMeWULG6s82opp2vo3s0ngiJ7Lu1iAYq2E/0BSzZ3M8Gu7wQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696984; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m6MHrYUDy32kDYPpsu7hQKmN53Ci3Cb0G+3ghuqtWGg=; b=AsMUdagEpjSOk3v0Hb9oErlkeLsYymimUfZ/kLzxlSsfHkgeFWSNZOvUpDQvOHiPO6+pqI18jpHhpMU8LxGUfhGaB7StO0Q8ZEfLLVfSBXI9/gWJBlvrAnTyE8txhICKrKf4wUTTsLEiVQLjeC8VN8tXGRVAnzSfcayD728xHtg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1752696984437697.503846660881; Wed, 16 Jul 2025 13:16:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045632.1415844 (Exim 4.92) (envelope-from ) id 1uc8Xs-0005hb-A8; Wed, 16 Jul 2025 20:16:04 +0000 Received: by outflank-mailman (output) from mailman id 1045632.1415844; Wed, 16 Jul 2025 20:16:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xs-0005gW-1i; Wed, 16 Jul 2025 20:16:04 +0000 Received: by outflank-mailman (input) for mailman id 1045632; Wed, 16 Jul 2025 20:16:02 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xq-0003uY-Nc for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:16:02 +0000 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [2a00:1450:4864:20::42f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b0cd02d2-6281-11f0-b894-0df219b8e170; Wed, 16 Jul 2025 22:16:00 +0200 (CEST) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3b60565d5f4so21603f8f.0 for ; Wed, 16 Jul 2025 13:16:00 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:59 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b0cd02d2-6281-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696960; x=1753301760; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m6MHrYUDy32kDYPpsu7hQKmN53Ci3Cb0G+3ghuqtWGg=; b=BunTHacQkHNvbg79bt9ZNGzoViavlNH8o5zdgAgwEVPtVEC3GaM7Cs6YJAzBj/k3xg vQWbyoitSDLzeHH53OhdItj9Cu9tH2Pv7H/adBxLQM0Thw03IeoSyS33RDwdwk+4J+FV 0jCpAzswBfkG5SEl4FZDiVduUBZov0fEm8xtFZornPktFoSrVG5z5KfYx38srV9e9Ukv j+LdqfkPeMBTyNEQTesHjZEpN0+HzL7G/iYzkQ2zH5H5RmqGblyForQCcv5csAgqsBpg 3VsxM8kNMu4DGM6s4D2i1Giv9FTaaWIbI9Lk4JKBS1fp4nQ4b7PU2kyhjEzDLJAQIX+d JCrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696960; x=1753301760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m6MHrYUDy32kDYPpsu7hQKmN53Ci3Cb0G+3ghuqtWGg=; b=a2pXdoUvkCL3qBFPdGVpQpkQuNd/KH4PVeg/WiKw3Pmbpu6ymcflLDpMICkvVuij2u vYh6fsQ/Ys6m4tggJsnESCSLM2X98xexDrnvXKCLRUEE4OXvgC+ilDN+XjAxnHnoeiAw Jl9T8FsfYCf6q0gM8pml2MVHOKoifMgdZbquxxibLC3WNV34B1gY3q+chdidGk+3MMFz LG27e59rlGCF0tyJpWohzwrlJFpW3ucgZ15GMx+AVzJFdQXzLwiGNjleYjENh68VsRaM G19LdwP1GCEaxRnqIUfGZWnMXEWO0wjer4Z1KeA1cadA6W6HLaBz0e2vK+tN3QlNrKMy 2P0A== X-Gm-Message-State: AOJu0Ywq+IiipomjgCE+PW7FI4Gr1d85S5ZRaW0bKdJ7VhGwjJuMTHVn QhSax+eGOrSg67Y2+SNsg2mZKZ4dpHAlGhqOPF+Lyt+nRHhcWYzBMwxwpcbkGA== X-Gm-Gg: ASbGnctQhDUvRgSEBK1jHQocyrpSAcQYPKAJ5o6SRyP7N7iJMFeKhm8SP7hlJ+hdGGp RDuGPTQtnDFy5dCQ6/QiSB3PBhK/f1B/VVbhGECs4pVagBxEBKASxv4CjPjy2s8+0Yu07Lk49kK MkWxESXLTJmzDpTZY2FgdBpGMwu9MN/a/cm7yYb7bm1PcX2E1wEUiOjU3YIfBJKQ26qlq3YM6zl Uh1DyNwtKo6q19QbnSk91Ih4GyibE440nUCblLb+St7GmH5/1kcX+44YSV+yOCElnorEqF+W0I2 IuJd6tdkWxuRY/d0yMo2DIw/in5Pof3lmPl8JG0phejhMu7Sc6pNrTkOu+ZmAofynrQIaSFvd6v EHaC9pnKWhj6leASvnQ8XDcc9isrxQUr2yNF9x2e9wq+LgaspnEpPuruGexG+cSI7xFOagYkW5n mfDIO2moeiWwdllRk9Vx8ntQ== X-Google-Smtp-Source: AGHT+IF5xzxZHGT15VC4mX8p6TolF+9HdTpdorS1QFcvjZqWeXsUxfPZeGpsYfbmoDurhIJKjFtR9g== X-Received: by 2002:a05:600c:4f0c:b0:442:e608:12a6 with SMTP id 5b1f17b1804b1-4562dff98b5mr19594225e9.1.1752696959624; Wed, 16 Jul 2025 13:15:59 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Christian Lindig , David Scott , Anthony PERARD , Christian Lindig Subject: [PATCH v10 9/9] tools/ocaml: Add altp2m_count parameter Date: Wed, 16 Jul 2025 20:15:39 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696985040116600 From: Petr Bene=C5=A1 Allow developers using the OCaml bindings to set the altp2m_count parameter. Signed-off-by: Petr Bene=C5=A1 Acked-by: Christian Lindig --- tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/ocaml/libs/xc/xenctrl_stubs.c | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index 7e1aabad6c..97108b9d86 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -87,6 +87,7 @@ type domctl_create_config =3D max_maptrack_frames: int; max_grant_version: int; altp2m_opts: int32; + altp2m_count: int32; vmtrace_buf_kb: int32; cpupool_id: int32; arch: arch_domainconfig; diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.= mli index f44dba61ae..9fccb2c2c2 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -79,6 +79,7 @@ type domctl_create_config =3D { max_maptrack_frames: int; max_grant_version: int; altp2m_opts: int32; + altp2m_count: int32; vmtrace_buf_kb: int32; cpupool_id: int32; arch: arch_domainconfig; diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index b51fd66788..ac2a7537d6 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -205,13 +205,22 @@ CAMLprim value stub_xc_domain_create(value xch_val, v= alue wanted_domid, value co #define VAL_MAX_MAPTRACK_FRAMES Field(config, 7) #define VAL_MAX_GRANT_VERSION Field(config, 8) #define VAL_ALTP2M_OPTS Field(config, 9) -#define VAL_VMTRACE_BUF_KB Field(config, 10) -#define VAL_CPUPOOL_ID Field(config, 11) -#define VAL_ARCH Field(config, 12) +#define VAL_ALTP2M_COUNT Field(config, 10) +#define VAL_VMTRACE_BUF_KB Field(config, 11) +#define VAL_CPUPOOL_ID Field(config, 12) +#define VAL_ARCH Field(config, 13) =20 uint32_t domid =3D Int_val(wanted_domid); + uint32_t altp2m_opts =3D Int32_val(VAL_ALTP2M_OPTS); + uint32_t altp2m_nr =3D Int32_val(VAL_ALTP2M_COUNT); uint64_t vmtrace_size =3D Int32_val(VAL_VMTRACE_BUF_KB); =20 + if ( altp2m_opts !=3D (uint16_t)altp2m_opts ) + caml_invalid_argument("altp2m_opts"); + + if ( altp2m_nr !=3D (uint16_t)altp2m_nr ) + caml_invalid_argument("altp2m_count"); + vmtrace_size =3D ROUNDUP(vmtrace_size << 10, XC_PAGE_SHIFT); if ( vmtrace_size !=3D (uint32_t)vmtrace_size ) caml_invalid_argument("vmtrace_buf_kb"); @@ -226,7 +235,8 @@ CAMLprim value stub_xc_domain_create(value xch_val, val= ue wanted_domid, value co .grant_opts =3D XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)), .altp2m =3D { - .opts =3D Int32_val(VAL_ALTP2M_OPTS), + .opts =3D altp2m_opts, + .nr =3D altp2m_nr, }, .vmtrace_size =3D vmtrace_size, .cpupool_id =3D Int32_val(VAL_CPUPOOL_ID), @@ -286,6 +296,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, val= ue wanted_domid, value co #undef VAL_ARCH #undef VAL_CPUPOOL_ID #undef VAL_VMTRACE_BUF_KB +#undef VAL_ALTP2M_COUNT #undef VAL_ALTP2M_OPTS #undef VAL_MAX_GRANT_VERSION #undef VAL_MAX_MAPTRACK_FRAMES --=20 2.34.1