From nobody Thu Oct 30 22:46:56 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=1752533356; cv=none; d=zohomail.com; s=zohoarc; b=TwJLObSkMDG6rRnpBg2mIMyWSeJ93HmlYk4RVkcSOyIRAbXOF6s8YejCep/nyiP61lYx7tWWD2ydIh4MZFsK/SZ4dPz3XSwYMhEQ8FrPDUqIjISwZ/s3Ueg0QsX74Fd+M50Sgp4LbpQWadphOcSVcXVYeWS3S6wTBpPTImmZOK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752533356; 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=h7PeFG4j0+6wg/8x4w0BGJXrwiGp05DFafVuw1va9HQ=; b=oHrRKO/ic6CiE7GEM6g6/xjhZF9R/V93L3tS3ZPWTM3zmtJH9dnggJxofsxmV1J1LRU+IdCthE1dCdiQVvHerKGIhz6gScGR7QcV2ac/DqIpMeftXYNDOOWAF7wP8PCwikh5BNRnwIvhtlQBHtvmsphJMSshYNM4a9qcR2UK8z0= 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 1752533356811825.9932640548658; Mon, 14 Jul 2025 15:49:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1043176.1413293 (Exim 4.92) (envelope-from ) id 1ubRyq-0004Lm-6y; Mon, 14 Jul 2025 22:49:04 +0000 Received: by outflank-mailman (output) from mailman id 1043176.1413293; Mon, 14 Jul 2025 22:49: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 1ubRyq-0004Lf-3W; Mon, 14 Jul 2025 22:49:04 +0000 Received: by outflank-mailman (input) for mailman id 1043176; Mon, 14 Jul 2025 22:49: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 1ubRyo-00040h-T6 for xen-devel@lists.xenproject.org; Mon, 14 Jul 2025 22:49:02 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bbf09e7f-6104-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 00:49:01 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3a4f64cdc2dso695760f8f.1 for ; Mon, 14 Jul 2025 15:49:01 -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 ffacd0b85a97d-3b5e8bd18ffsm13288903f8f.9.2025.07.14.15.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 15:48: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: bbf09e7f-6104-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752533340; x=1753138140; 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=h7PeFG4j0+6wg/8x4w0BGJXrwiGp05DFafVuw1va9HQ=; b=HCNClcgDpCElMafVOCroI8gklpeVDR8wuBn44JSvT1+f9I2HMQUPsADtx9ZdDs+W38 eV5JUYhfBpBxff15C57jvSBfXG/MWM9t2mbD4RRrGE+wEo6mSpG0rvlVX0zh1sNBnHk4 t0z+djHWZGmydu8z9K+YWEFXzipP/xl+bncQkGlkLq7ACBvOQUxN/8TycPeLRdQGZUUs 4ziZxtX1wjoVuQ72aa2OeFsMe7VOOjVG84lNzbF5/KNTq4t/eYknX7HmNzj8/zt95hIz r9atqNw4ItQKlAiTWMpzOONWCZKj1AG09PHa2cxJXOaVKDvtSB837k3Oz6y2KwHQMl0+ GCow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752533340; x=1753138140; 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=h7PeFG4j0+6wg/8x4w0BGJXrwiGp05DFafVuw1va9HQ=; b=b1jZXHIwEyYSU/IZ2VWeE0b/dMkJyVlreULLrQhnvImYguVoYK62d0R8IJaqtgiQYJ a9YdUdzTEaHpmf2Wxbolc2Hht75ORmoX8CBOI9MTuGCEtlbKruyFN9x5YucniL639DPe g1zYap7T2gcN/BdMlkBGSejPGE1silhbj/tRDM6Eg1EDb/P5mwfSVUnzZzWCSQ6npkHJ gVYdBES0TTQdqmLx7NCI5/jBhAxc1MMuz+SIFyAkxiz1ceLpByVzRI1uf9OhA4tiSCya uiM5ytJmhWKS41OqbntIYlc4oV3DrZkOAEVJn08JfCreqLtfrxyH29eIfV/owfCRSrFA 4yuQ== X-Gm-Message-State: AOJu0Yz9+zEhhDcjLaBiFwIRq1NTrQh0RAd3QU2IkrBq92Nl5gJJ75Ns 5gy8NXJDxFn8GEzi+4zOCdxgun/vBprHUFr3izswdNu4yD3o2UHDVvKYjQOsoA== X-Gm-Gg: ASbGnctTToiu3/ExgkRPocNYYL9Oj3gYJe4S31AXZzxFUDXk78HCuJAHM4slNq5b1Yu JoDPwFYIuswpJTAbLFUhQGTTKOqdAVQW1Z6ZcEVj0iSToLizU1dLtelq1Oj97PVnUbrSrxNa76V RK9G+2lYvrFeL4yehZfg8lAfFJm4BIeNWjR38Nk/BbzUaVUo3OToVf1/vWMdbIsIKwb1LoA+7iK z+pPXt08yye2CFIE/xSfVkPxSOmy7DyrEvv8GoPKFMH3cEnh3CiRgKKKXxtLzb7dVVwI3Tg+roB CmCLOuA9MdgPBVOdNd4pzPJKVzJchOym1nNXpm+awIW3PX0iMzJFH0PJX+Pfu1KKFn3/mQyiDk/ ku9iy0hbtPwm+XTPXHUXkalU74r22aEuxeDRUy0giTNZ/Vg4cabI7UJXt22VATJhNu/lz+taZ9O 3m/JPDGtRBzvAhpElWJ9Brkg== X-Google-Smtp-Source: AGHT+IEq1c3ozI1xTvwm7eOIJ9g+ASHaw5Ngv2QUus83unSuu4Z/ZANkRIUMcuqvYPKy8lsTfs0i0g== X-Received: by 2002:a05:6000:2388:b0:3a3:6e85:a550 with SMTP id ffacd0b85a97d-3b5f185a966mr4950180f8f.5.1752533340066; Mon, 14 Jul 2025 15:49:00 -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 , Andrew Cooper , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Christian Lindig , David Scott , Bertrand Marquis , Volodymyr Babchuk , Christian Lindig , Julien Grall Subject: [PATCH v8 1/7] xen: Refactor altp2m options into a structured format Date: Mon, 14 Jul 2025 22:48:48 +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: 1752533357920116600 From: Petr Bene=C5=A1 Encapsulate the altp2m options within a struct. This change is preparatory and sets the groundwork for introducing additional parameter in subsequent commit. Signed-off-by: Petr Bene=C5=A1 Acked-by: Christian Lindig Acked-by: Anthony PERARD Acked-by: Julien Grall # arm Reviewed-by: Jan Beulich # hypervisor --- tools/libs/light/libxl_create.c | 6 +++--- tools/ocaml/libs/xc/xenctrl_stubs.c | 4 +++- xen/arch/arm/domain.c | 2 +- xen/arch/x86/domain.c | 4 ++-- xen/arch/x86/hvm/hvm.c | 2 +- xen/include/public/domctl.h | 4 +++- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index 9525d22312..8a85fba1cf 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -622,17 +622,17 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_co= nfig *d_config, LOG(DETAIL, "altp2m: %s", libxl_altp2m_mode_to_string(b_info->altp= 2m)); switch(b_info->altp2m) { case LIBXL_ALTP2M_MODE_MIXED: - create.altp2m_opts |=3D + create.altp2m.opts |=3D XEN_DOMCTL_ALTP2M_mode(XEN_DOMCTL_ALTP2M_mixed); break; =20 case LIBXL_ALTP2M_MODE_EXTERNAL: - create.altp2m_opts |=3D + create.altp2m.opts |=3D XEN_DOMCTL_ALTP2M_mode(XEN_DOMCTL_ALTP2M_external); break; =20 case LIBXL_ALTP2M_MODE_LIMITED: - create.altp2m_opts |=3D + create.altp2m.opts |=3D XEN_DOMCTL_ALTP2M_mode(XEN_DOMCTL_ALTP2M_limited); break; =20 diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index 863ab3c778..b51fd66788 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -225,7 +225,9 @@ CAMLprim value stub_xc_domain_create(value xch_val, val= ue wanted_domid, value co .max_maptrack_frames =3D Int_val(VAL_MAX_MAPTRACK_FRAMES), .grant_opts =3D XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)), - .altp2m_opts =3D Int32_val(VAL_ALTP2M_OPTS), + .altp2m =3D { + .opts =3D Int32_val(VAL_ALTP2M_OPTS), + }, .vmtrace_size =3D vmtrace_size, .cpupool_id =3D Int32_val(VAL_CPUPOOL_ID), }; diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index be58a23dd7..79a144e61b 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 ) { dprintk(XENLOG_INFO, "Altp2m not supported\n"); return -EINVAL; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index b67342797f..56c3816187 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -622,7 +622,7 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) bool hap =3D config->flags & XEN_DOMCTL_CDF_hap; bool nested_virt =3D config->flags & XEN_DOMCTL_CDF_nested_virt; unsigned int max_vcpus; - unsigned int altp2m_mode =3D MASK_EXTR(config->altp2m_opts, + unsigned int altp2m_mode =3D MASK_EXTR(config->altp2m.opts, XEN_DOMCTL_ALTP2M_mode_mask); =20 if ( hvm ? !hvm_enabled : !IS_ENABLED(CONFIG_PV) ) @@ -709,7 +709,7 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) return -EINVAL; } =20 - if ( config->altp2m_opts & ~XEN_DOMCTL_ALTP2M_mode_mask ) + if ( config->altp2m.opts & ~XEN_DOMCTL_ALTP2M_mode_mask ) { dprintk(XENLOG_INFO, "Invalid altp2m options selected: %#x\n", config->flags); diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 056360d5fe..56c7de3977 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -665,7 +665,7 @@ int hvm_domain_initialise(struct domain *d, d->arch.hvm.params[HVM_PARAM_TRIPLE_FAULT_REASON] =3D SHUTDOWN_reboot; =20 /* Set altp2m based on domctl flags. */ - switch ( MASK_EXTR(config->altp2m_opts, XEN_DOMCTL_ALTP2M_mode_mask) ) + switch ( MASK_EXTR(config->altp2m.opts, XEN_DOMCTL_ALTP2M_mode_mask) ) { case XEN_DOMCTL_ALTP2M_mixed: d->arch.hvm.params[HVM_PARAM_ALTP2M] =3D XEN_ALTP2M_mixed; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index be19ab5e26..a69dd96084 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -99,6 +99,7 @@ struct xen_domctl_createdomain { =20 uint32_t grant_opts; =20 + struct { /* * Enable altp2m mixed mode. * @@ -115,7 +116,8 @@ 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 altp2m_opts; + uint32_t opts; + } altp2m; =20 /* Per-vCPU buffer size in bytes. 0 to disable. */ uint32_t vmtrace_size; --=20 2.34.1 From nobody Thu Oct 30 22:46:56 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=1752533360; cv=none; d=zohomail.com; s=zohoarc; b=QxGGjEjxq5f2ATewc30EvJRIBH4FKL11S8RS3NeKOeDBgKLABXtsw1InAgeVjINOL0bMdp7CQ35MlpWXlNdMJsbh2SWc7DVF4UVwoQMkikLnkb4lqpdVGxuOCYyUC7Z12MsusDtZdsu8yz3jCIvQtFNEgFsyn1QZwJ+jmTlh3TE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752533360; 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=bMqLQnIMKiHopoJMrr88JijFjKqoXgm8Q4/2Wpe2f4w=; b=KTwfqyXm343JSa7LdgDrgITHqvayUm1VFlCYQ0WqpVYHrqlqTAyDseBl3gspbpNXqnzSFl+oRf8Un2E18qO1ljlomwriN+n7YHSw74nvEYaFQowNI842QrdBfbNDD19Rm4fvHuxKFOqjxV74h8vcd+uEAK3/8+FgUeZo4k/vDM0= 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 1752533360226439.3377134663025; Mon, 14 Jul 2025 15:49:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1043177.1413303 (Exim 4.92) (envelope-from ) id 1ubRyr-0004af-Gf; Mon, 14 Jul 2025 22:49:05 +0000 Received: by outflank-mailman (output) from mailman id 1043177.1413303; Mon, 14 Jul 2025 22:49:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubRyr-0004aS-CE; Mon, 14 Jul 2025 22:49:05 +0000 Received: by outflank-mailman (input) for mailman id 1043177; Mon, 14 Jul 2025 22:49:03 +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 1ubRyp-00040h-TJ for xen-devel@lists.xenproject.org; Mon, 14 Jul 2025 22:49:03 +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 bc810162-6104-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 00:49:02 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3a524caf77eso510140f8f.3 for ; Mon, 14 Jul 2025 15:49:02 -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 ffacd0b85a97d-3b5e8bd18ffsm13288903f8f.9.2025.07.14.15.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 15:49:00 -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: bc810162-6104-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752533341; x=1753138141; 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=bMqLQnIMKiHopoJMrr88JijFjKqoXgm8Q4/2Wpe2f4w=; b=kY1+Ue5QGyMZI/geqj/sYfQwPEvbGZx5lxIv2d1QtmAQeyVTz/njvn5hJo57X+gRoh QuSprkOXI90MaKbPsTOXbmn61vbmLG/LMJZPLWUMn4FBcX8SJdVGysTq/C5f+MtZBipZ nHFF1wItcia0y0sCaQiemJRdleQtdvZYZFwB/FyIWB2nZ8qK1+Zg2uh51Kf5eQRqzyD9 C4c+C4y/66fQ/6qux2vMixnfXWSwlX1AZmd9roWoFwJKLp13m/Fp9/0UUVeYG+g6+ur4 CNsikysC+4gcBXa6V2iQUw9dRAFjdwofzysrdU3eHG9bcgm7eiI6m+qFWflScUFEDYhL yRgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752533341; x=1753138141; 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=bMqLQnIMKiHopoJMrr88JijFjKqoXgm8Q4/2Wpe2f4w=; b=QEqvZiTkBquV0fi2Eq9fviZxTJRLQP93lyVugZO7hFm7yT2TgkB99ZFKDD6K8FYN6n HG1/bgUi6YfcrPdSMvEeD1nntEozPrEhXtnGMXIsvgkzLxevwT0l8nitzeCm9AV1GVlM zO2GG8kQoNIAT3VcmOdvok7gmfH3YB4Qh/I5Pxmt5Mld45/arI1W6sV2H7cE2qUq7GCq tzQj2QhcOziTMW8AHdJJ2ctSrgNmHRTRXx8qP4HtS2UyVQN7CQuQShedT/6ZVORXcYsp WWg6IzUvSEBFDOOTwIkMZvM2PLYMT5D/vzB8gHkEIQbZ2rGF2KdwzCHgA2ZbCsGvd4Aa RMQw== X-Gm-Message-State: AOJu0Yxu3pdHrUj1HQFdhxZ7l1m7S4HPSMY8VTKHwswYZwzoDUf2lF/D rxIQiz+OEU0QRipWzczjC3KK0epxrR3U3IMkZBae2LxgrDRfiBvz2eM+16LScw== X-Gm-Gg: ASbGncuDUJzkfynEK+gGGdJd+UfHVDNujefVwtgvj+nJkDPdS7I+6YSy5RmETOOdv0s Wd+rEdB78u4BVDO4AqWbWfvAFx10zO/ZkCNFO7d5RZF8pfkQef0GqL16enrrZv4mNu1czHOXTuK gr4ueSEmb+FOlYCaUjTg2cGEp24B5pCkvrHvXTtKMSuEXSDtKTEXh9TOpEHEtd1xjFBs0Gpmw/e kJZeLxF0Oy5mGk86N4sD4vFm+llbX/P7Ebd4iBYcevfi7xP0V2yfmYaDGuPdssVh6t/DzTpz4HT 0UZJx9y+wGr04rxBBUt3QBtnheZ9TYVNs7buCcr/cRZxDhyYNIKLmmlUCafsoOny/UIeYkEOt2J sG8/3GnDL9qruxl2uVlnWCYeBdk5/1JxrN6qgMzkvyrgGEbBKjWOFWC7SHggr56a52QSfaYkVhJ osdzgpTubzb/amnhjLZm4HfQ== X-Google-Smtp-Source: AGHT+IFdUH8uiuQCaPsONKhfIwTR/YdU57KM9HndV4yRuENg/h8i7UYpLlLmYLGHjxf+m6MZUdHGkQ== X-Received: by 2002:a05:6000:2285:b0:3a4:ec9c:fb58 with SMTP id ffacd0b85a97d-3b5f18e7c75mr4107493f8f.9.1752533341012; Mon, 14 Jul 2025 15:49:01 -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 v8 2/7] tools/xl: Add altp2m_count parameter Date: Mon, 14 Jul 2025 22:48:49 +0000 Message-Id: <56d4d4b2bb7789a606f21c61e5d294ca2e624528.1752531797.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: 1752533362268116600 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 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:56 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=1752533359; cv=none; d=zohomail.com; s=zohoarc; b=hoUrqjhqiEVJdMUM7JTi6lxRM2gjksuId8KYHOrEHGPyQJYEUqaCg2cJsYEnYgMELogYEs4dZIkrPtWFXajtmEVu9sr0BhIK5AnWYWv+misc98JINaDKlUladV8zmifhrC0cuSPtUvY7/9lLGu6SANVskE4457bYlXzK5JsY4jE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752533359; 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=CSwXh0f7SkkaYdnjlAbgKzZg+uE2aLaKLdnCLfIyAK9OcutKntqcWhRAX1aw2W+uMxwKhsyGPWLiujz0RRrYvdi/K8La1VEMuVqfFjBFhhruSoZsxqitLwsLWlaRzkOL/qcHSmWcInwAo+lUl7xutZ5SM1hxLh0SH1C4W83yoMM= 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 1752533359419267.0557629711325; Mon, 14 Jul 2025 15:49:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1043178.1413309 (Exim 4.92) (envelope-from ) id 1ubRyr-0004eI-So; Mon, 14 Jul 2025 22:49:05 +0000 Received: by outflank-mailman (output) from mailman id 1043178.1413309; Mon, 14 Jul 2025 22:49:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubRyr-0004dS-KB; Mon, 14 Jul 2025 22:49:05 +0000 Received: by outflank-mailman (input) for mailman id 1043178; Mon, 14 Jul 2025 22:49:04 +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 1ubRyq-00040h-TO for xen-devel@lists.xenproject.org; Mon, 14 Jul 2025 22:49:04 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bd08db91-6104-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 00:49:02 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3a4e575db1aso268195f8f.2 for ; Mon, 14 Jul 2025 15:49:02 -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 ffacd0b85a97d-3b5e8bd18ffsm13288903f8f.9.2025.07.14.15.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 15:49:01 -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: bd08db91-6104-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752533342; x=1753138142; 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=dfAA7JPDe9gmYQb/NaQsfED72tYqUB8+NurRd/G3ax8S6TspPK4VdVbdVlmIBDhL44 NvFw9/93czJ2ui4TH5p9/DFLKBNBRSxxrcrkEWn/x8TvibE99GfZ9bqbIoSL58pQv1KW gR0Vi7VSFgn2A+q2shv6OSa5wTlovkf7aMrK7fRmgcpyVI+vZGz8d8U/AMmdzIJrCT85 IVSyJgtNbCHg3L0fJ0kx6Wa9ihhZEOFU0XMe+8QGXvsS+jsy7jCyQg72LNGH3SKGJ3VU t1e9WB8W6BxvIUGcCOfs1aka54WV6Ly/R4/W8cg6SxBeaB2LowkxsQI3FyUfU/R1g2x3 Xtug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752533342; x=1753138142; 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=DM/2pnvCJIIKJNnbvloH/o1TIT+76su9YxjZfaaauDCmupkRYsL1it9jempr4MlMi5 RR/F494tVT4OwG4WCbRg/zllpKTuK84uPF7HXLDmLaj33671qEC/PDPv3sjF/2M0HLKX M1vxa66Eq3H/NOLFO4SX2XLgczzvGDo3NFXavhYwMED0AFJdSp5UAtutsKsIoCF3MSS6 ZOu9gA2GtYmLXgbXqYcZhvPWO14+LacYkcvIRMymtTZEH9NDPzkkZfkdyKWJn7It1LUj 9W952cLvxi+lwcbk0uC/3F646QVKHi7H1VPwnQItxwZEbiajA1wxnDNvZgPBQBwu/Gvb a9GQ== X-Gm-Message-State: AOJu0Yzt5kKvnS/qUEby3+rwDsdlOmItsQZ4shG6CwxYBBjiwspdrXAd 5G7ogrFG4fPRbckCD8b97GybAYecF3O3mTpiHclSiQgsdpdosyiClvCaP0wDoQ== X-Gm-Gg: ASbGncuLuVz4kKZJ0kgIENZhBEsgbXlKYEZZh0zpl5xccCLdI3/CSbuFosjBBa0dL5D KD/l/BCnRwJsadRaV0oZhqnDnuz+3yA+8OFqbjNUaxC8knSnvJ6GpDpKil0/PH7BM/ItsP0Z3CM bqsssuva/8spygZSf7E0OVO4hf7tKuuuI2262KIk4N2B0U54eJubanRKK2qyxLPXymvekj+Oy1X cIyEnSazXJQF0NdFSMhf3M4fnBEcCf7/F3awLeg4rN/9fixGKGuPsoKUKj4U0a8K710CPlkheUS rsvK7N0oy/56W2R2EfSHlQHnM0C9WFISA0PQXwjW2s3xaJJbJchH70g1noWiSs9TxFSpV96w3ci 6v55mLNcM9JGIxwhprQ27rH2SHTdb0SRHmiiYEgZSsOboi0qS68W2eoYdEePEXUMk0NOA1CnDCZ eNozQSa5KLoangHQ9YZ8cZHQ== X-Google-Smtp-Source: AGHT+IHS8m8AnrVA1AYpx7j+9GYNiQTp9QbybzArFtYabZVNom9umZhMZo12kJI17sriMaI0pWF7Gg== X-Received: by 2002:a5d:5d83:0:b0:3a6:ed68:cef9 with SMTP id ffacd0b85a97d-3b5f2de5e18mr3680487f8f.3.1752533341712; Mon, 14 Jul 2025 15:49:01 -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 v8 3/7] docs/man: Add altp2m_count parameter to the xl.cfg manual Date: Mon, 14 Jul 2025 22:48:50 +0000 Message-Id: <8ae729912e4aadf5ba8eb70d8d779e691858f4b9.1752531797.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: 1752533359848116600 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:56 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=1752533367; cv=none; d=zohomail.com; s=zohoarc; b=DYMFXSoPlyw8G5FptFPJOoipwf18ZRU1/gkE9/PO9dil+2uKWvBvPnRq8PqZ51qlHiZA4KJIPq7QKBiYE/jkf40dau0VCtiBAxt9aOFuSQl/zVI3ph84Uu9crV2PcCgXDE6mdsGPrWaZ6rEoYtXAj9pa3c6RyV+OpSx2xcfci88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752533367; 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=KGMPeQfE6BdXdbIBfumLa4Wdomd7Xq00xQ0dyh4Tdlg=; b=Hc+isx9S7ej221Qv0tM1SdECvfXEsEdUthmfcFHWHDtco9DfN/VPZ4M1D1B0rFUF3sf+/txys19mvejVpqEHuh8RSf6dauPdR7n1r+US6k3WgTu1QFtrDSaRd95Dv1AzhPruuXO80LLWfouiO/GjIhwx5qmyw+5Uy8OrZmvJULU= 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 1752533367900269.45001927005967; Mon, 14 Jul 2025 15:49:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1043179.1413323 (Exim 4.92) (envelope-from ) id 1ubRyu-00055o-2J; Mon, 14 Jul 2025 22:49:08 +0000 Received: by outflank-mailman (output) from mailman id 1043179.1413323; Mon, 14 Jul 2025 22:49:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubRyt-00055b-Th; Mon, 14 Jul 2025 22:49:07 +0000 Received: by outflank-mailman (input) for mailman id 1043179; Mon, 14 Jul 2025 22:49:07 +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 1ubRys-00047A-No for xen-devel@lists.xenproject.org; Mon, 14 Jul 2025 22:49:06 +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 beaff253-6104-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 00:49:05 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3a4eb4dfd8eso721779f8f.2 for ; Mon, 14 Jul 2025 15:49:05 -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 ffacd0b85a97d-3b5e8bd18ffsm13288903f8f.9.2025.07.14.15.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 15:49:03 -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: beaff253-6104-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752533345; x=1753138145; 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=KGMPeQfE6BdXdbIBfumLa4Wdomd7Xq00xQ0dyh4Tdlg=; b=HF8CIoAlMiUn188KHVBbY437GXOL3ch+3GHmXqZvsYy36gHm7QcfHIxS8QITcNvRPG gePU1MRoQwuVvbtLfS9+HGTicI/O5tgrj4a5ezunNlVr0qvUDx69jzMx5OIRiz5b3XGN 6XU337Pnisxhp1vNmVW5uRxXNyAHEei9Yy6hSNY1aOYTDMXnfsO7UYwIUGPemFBZYhdJ HTlW55vkdQxRVFiOtfYmQRJf6CfSlRa/DLFNu0vUQS1hqirLgR30YZK3fDAFc3Cs09uI 7oCRHiMPcdKjMoW1uEjVQO+C9nUNeTVG16o2id0azDX17F2mGuLfh5yEeLh46LSwuTxk WpdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752533345; x=1753138145; 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=KGMPeQfE6BdXdbIBfumLa4Wdomd7Xq00xQ0dyh4Tdlg=; b=gpA7fJY3XH56Lx9itKDIeABeC/KX/GrQYepOZSDUIqM4FmuO2Abc1TOop7QE1CdT45 XfqVRE2i2WwC9xQZS3es2cJkNjfcfzggovh3/pUBJr0d1NZk+2A8xjkRlLKKw6B5Ugne ti/+y1M2+LhyYwK3rpm/95F1N7bzsbTPTe89BOH9/mI23n8goS4HmFC0qCD+W1eYefsl eukJ9JImygc5/E8eC3vzIoZudZ/Uz36FoWA6JrLpQfVd9nBhPKC9VNtL7zoB1ebMzv6v umlzGdboDjTDiWMRpRv0kkkSGGJwZeLv3q0BryXgpTw7T+PLRhjSGb+Kul0PqgqBPVgK xeEQ== X-Gm-Message-State: AOJu0YwydZHAc6pM2l6qDSwq74KtQrEYLX1ZO6wwTSSWMx29L8g3VD6r xeTfOgbr8GgF1+XLQOkNrEjpry181QYDgWckx4CvvDy5Ky515yck23QA4HVK8w== X-Gm-Gg: ASbGncuJDwtEgLq77y5tyGBzADk3O83InDRisYMcQICDtuyZtY2+hwkiVuLRS23XI2H xNz808hXtAsLXJbo+dGia179s8Ctrw+VqXpEiLKYvUMVGxMux3HarhqKaGgCyAJQlnuH6b0SN5H 6ZOvDYui/hXWRKKXVT2DlF1sJA6OgRBJ0VQHVo6pkNC5lc5m1z8icUM70ROXm9u4EDgycAahLqT LnoAwcCf+lunQWBM9vwHfeYYApqCcQ5w5AAx66/koN9DDutYdRAugT+SIYi2jsCKHsTQ3PJjjT1 U0otjqD5FE/2tnLcXs1yjVetgiiKAAzKi2RnH7VIcNPvSR9W7UY+16xMGOLkfXc6c7YoAZX1KaV nzkIlbshXxxcGmqj6lGgUCsMU+YnOX//CYdGkhIvUO19nZSk2CDjgUxrk3MjlVuOsFUDHDxZssX JSNnz+GCaQSW2TBAer5eFA4g== X-Google-Smtp-Source: AGHT+IGhiaTjzKMRquDY+aHyzaSdmZF8dAn8rEcenDHke9C/yx8SXl1hx3qrt10uPl8fN97EtVCsOA== X-Received: by 2002:a05:6000:24c7:b0:3a3:63d3:368e with SMTP id ffacd0b85a97d-3b5f17f2fdcmr4614550f8f.0.1752533344383; Mon, 14 Jul 2025 15:49:04 -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 v8 4/7] xen: Make the maximum number of altp2m views configurable for x86 Date: Mon, 14 Jul 2025 22:48:51 +0000 Message-Id: <6f6b6017ea1db89b8e07aaeb66550f3d117ef44c.1752531797.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: 1752533370236116600 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. Altp2m features are now guarded by #ifdef CONFIG_ALTP2M. 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 --- xen/arch/arm/domain.c | 2 +- xen/arch/x86/domain.c | 40 ++++++++++++--- xen/arch/x86/hvm/hvm.c | 20 +++++++- xen/arch/x86/hvm/monitor.c | 2 + xen/arch/x86/hvm/vmx/vmx.c | 12 ++++- xen/arch/x86/include/asm/altp2m.h | 28 +++++++++-- xen/arch/x86/include/asm/domain.h | 11 +++-- xen/arch/x86/include/asm/hvm/vcpu.h | 4 ++ xen/arch/x86/include/asm/p2m.h | 26 +++++++--- xen/arch/x86/mm/altp2m.c | 75 ++++++++++++++++------------- xen/arch/x86/mm/hap/hap.c | 12 +++-- xen/arch/x86/mm/mem_access.c | 34 ++++++++----- xen/arch/x86/mm/mem_sharing.c | 4 +- xen/arch/x86/mm/p2m-ept.c | 15 ++++-- xen/arch/x86/mm/p2m-pt.c | 2 + xen/arch/x86/mm/p2m.c | 17 +++++-- xen/common/domain.c | 3 ++ xen/include/public/domctl.h | 5 +- xen/include/xen/sched.h | 4 ++ 19 files changed, 232 insertions(+), 84 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 56c7de3977..78d65abe1f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1873,6 +1873,7 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned l= ong gla, P2M_ALLOC | (npfec.write_access ? P2M_UNSHAR= E : 0), &page_order); =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(currd) ) { p2m =3D p2m_get_altp2m(curr); @@ -1891,6 +1892,7 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned l= ong gla, } } else +#endif p2m =3D hostp2m; =20 /* Check access permissions first, then handle faults */ @@ -4608,6 +4610,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; @@ -4674,6 +4677,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 @@ -4944,6 +4953,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 +5247,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,17 +5277,19 @@ 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() ) return; =20 - if ( p2midx >=3D MAX_ALTP2M ) + if ( p2midx >=3D v->domain->nr_altp2m ) return; =20 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/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/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 218cb2c1af..4b8f0acbc1 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, @@ -4225,6 +4231,7 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_re= gs *regs) /* Now enable interrupts so it's safe to take locks. */ local_irq_enable(); =20 +#ifdef CONFIG_ALTP2M /* * If the guest has the ability to switch EPTP without an exit, * figure out whether it has done so and update the altp2m data. @@ -4256,6 +4263,7 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_re= gs *regs) =20 p2m_set_altp2m(v, idx); } +#endif /* CONFIG_ALTP2M */ =20 if ( unlikely(currd->arch.monitor.vmexit_enabled) ) { @@ -4963,11 +4971,12 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu= _user_regs *regs) single =3D ept; } =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(currd) ) { 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; @@ -4981,6 +4990,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/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 8c0dea12a5..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; @@ -351,12 +352,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]; + struct p2m_domain **altp2m_p2m; 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/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 4358cc15a2..262ddf8819 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -893,6 +893,8 @@ void cf_check nestedp2m_write_p2m_entry_post( * Alternate p2m: shadow p2m tables used for alternate memory views */ =20 +#ifdef CONFIG_ALTP2M + /* get current alternate p2m table */ static inline struct p2m_domain *p2m_get_altp2m(struct vcpu *v) { @@ -901,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]; } @@ -911,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; @@ -962,16 +964,24 @@ 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 +#else /* !CONFIG_ALTP2M */ +static inline struct p2m_domain *p2m_get_altp2m(struct vcpu *v) +{ + return NULL; +} + +static inline bool p2m_set_altp2m(struct vcpu *v, unsigned int idx) +{ + return false; +} + static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) {} -#endif +#endif /* CONFIG_ALTP2M */ + +#endif /* CONFIG_HVM */ =20 /* p2m access to IOMMU flags */ static inline unsigned int p2m_access_to_iommu_flags(p2m_access_t p2ma) diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c index 6fe1e9ed6b..dc6f310379 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 =3D=3D 0 ) + 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 =3D=3D 0 ) + 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,10 @@ void p2m_teardown_altp2m(struct domain *d) unsigned int i; struct p2m_domain *p2m; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + if ( !d->arch.altp2m_p2m ) + return; + + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( !d->arch.altp2m_p2m[i] ) continue; @@ -151,6 +166,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 +217,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 +323,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 +349,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 +365,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 +405,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 +432,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 +454,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 +467,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 +492,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 +527,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 +587,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 +610,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 +674,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 +741,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 +774,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 ec5043a8aa..4aec98109d 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 */ @@ -515,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 ) @@ -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++ ) + for ( i =3D 0; i < d->nr_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() ) { @@ -590,13 +595,14 @@ 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 ) 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..079c63cbf9 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -79,8 +79,11 @@ bool p2m_mem_access_emulate_check(struct vcpu *v, struct domain *d =3D v->domain; struct p2m_domain *p2m =3D NULL; =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(d) ) p2m =3D p2m_get_altp2m(v); +#endif + if ( !p2m ) p2m =3D p2m_get_hostp2m(d); =20 @@ -143,8 +146,11 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long g= la, vm_event_request_t *req; int rc; =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(d) ) p2m =3D p2m_get_altp2m(v); +#endif + if ( !p2m ) p2m =3D p2m_get_hostp2m(d); =20 @@ -347,16 +353,16 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, = uint32_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 ) { - 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 if ( !xenmem_access_to_p2m_access(p2m, access, &a) ) return -EINVAL; @@ -403,16 +409,16 @@ 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 ) { - 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 p2m_lock(p2m); if ( ap2m ) @@ -462,6 +468,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 ) @@ -469,13 +476,12 @@ 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 return _p2m_get_mem_access(p2m, gfn, access); } @@ -486,10 +492,11 @@ void arch_p2m_set_access_required(struct domain *d, b= ool access_required) =20 p2m_get_hostp2m(d)->access_required =3D access_required; =20 +#ifdef CONFIG_ALTP2M 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 @@ -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/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 0cf6818c13..06d46731a1 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -771,8 +771,10 @@ bool ept_handle_misconfig(uint64_t gpa) bool spurious; int rc; =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(curr->domain) ) p2m =3D p2m_get_altp2m(curr); +#endif =20 p2m_lock(p2m); =20 @@ -994,12 +996,14 @@ out: if ( is_epte_present(&old_entry) ) ept_free_entry(p2m, &old_entry, target); =20 +#ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() && entry_written && p2m_is_hostp2m(p2m) ) { ret =3D p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt= , p2ma); if ( !rc ) rc =3D ret; } +#endif =20 return rc; } @@ -1297,11 +1301,12 @@ static void ept_set_ad_sync(struct domain *d, bool = value) =20 hostp2m->ept.ad =3D value; =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { 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 @@ -1315,6 +1320,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,9 +1512,11 @@ 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); + 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 @@ -1527,7 +1535,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; @@ -1545,6 +1553,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-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 b9a7c2dc53..e802f2e4e6 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -101,11 +101,12 @@ 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; =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) ) { @@ -117,6 +118,7 @@ void p2m_change_entry_type_global(struct domain *d, } } } +#endif =20 p2m_unlock(hostp2m); } @@ -145,11 +147,12 @@ 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; =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) ) { @@ -161,6 +164,7 @@ bool p2m_memory_type_changed(struct domain *d) } } } +#endif =20 p2m_unlock(hostp2m); =20 @@ -930,11 +934,12 @@ 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; =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) ) { @@ -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,11 +1010,12 @@ 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; =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) ) { @@ -1022,6 +1030,7 @@ int p2m_finish_type_change(struct domain *d, } } } +#endif =20 out: p2m_unlock(hostp2m); diff --git a/xen/common/domain.c b/xen/common/domain.c index 303c338ef2..9baa7dd0de 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -811,6 +811,9 @@ struct domain *domain_create(domid_t domid, if ( config ) { d->options =3D config->flags; +#ifdef CONFIG_ALTP2M + d->nr_altp2m =3D 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:56 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=1752533371; cv=none; d=zohomail.com; s=zohoarc; b=X38iO+W9M6LijHTnYjLcKEBz/nOTUtMOdxygDdN9YgKsvtP+7fBBkPxNTmAxEL6HNCk/DgoRhIgn0Ka+zYEytalnaTbUJRKORZgdVfYCFtuMZ1g7Z9OhVeHKvn6YTX7sHEqqt9pSf6MhhnboCeO4H+EhGfeyWhN9VgIcj6G7Nas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752533371; 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=KzVge0WhvnuVttPV/LhRoGJuZaQZ5ZzS84Nnh7ALZH3IoGOM3CMwxBGmkYh/0lnkvPyU8HPZf0czOaXosM3/GDufOIiDSs+jwUUhlftR9wr+oFJtKeEMsGPwSCC6vjW7UXp37wUmp316vrId+M2Obl/N/CAKwW8RXFv42SL+PPQ= 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 1752533371261280.88021464666224; Mon, 14 Jul 2025 15:49:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1043181.1413338 (Exim 4.92) (envelope-from ) id 1ubRyw-0005Tv-Qk; Mon, 14 Jul 2025 22:49:10 +0000 Received: by outflank-mailman (output) from mailman id 1043181.1413338; Mon, 14 Jul 2025 22:49:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubRyw-0005Se-I8; Mon, 14 Jul 2025 22:49:10 +0000 Received: by outflank-mailman (input) for mailman id 1043181; Mon, 14 Jul 2025 22:49:08 +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 1ubRyu-00040h-Cz for xen-devel@lists.xenproject.org; Mon, 14 Jul 2025 22:49:08 +0000 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [2a00:1450:4864:20::42d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bf5edeae-6104-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 00:49:06 +0200 (CEST) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3b39c46e1cfso592674f8f.3 for ; Mon, 14 Jul 2025 15:49:06 -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 ffacd0b85a97d-3b5e8bd18ffsm13288903f8f.9.2025.07.14.15.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 15:49:05 -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: bf5edeae-6104-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752533346; x=1753138146; 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=kJGuT7qgyoMy1AOopjqI4XcDR3d74m0Go0zVGLdrLrft/tDZXzwbcEVMJFOTIg+ul/ z2vOkElLxOBEHLtoTZLdc0kumcUpWPW7wumLZZ40adNJXr/YNpFcVqBl4SNd06FEZX5X ue3gywsVcu6imXagUqYzAiQdTjg23mEfek+6TDGZvUBFby775uCcRaSBGs2fmzoUrXHR SOFJcKfSVUwfYDBoi7CRuKgPVcPp7AlAa3EDBj0wLAwBExHDOdMFgI0POCilTSYH1BLg 0rraMTmJdkGarFWw7wc76RO2xuwm+kJ2fMi8hs2O/bu2j1yQ76QnzaKvjNRREtwyfiFx 31uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752533346; x=1753138146; 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=C+76LROfXEHZdQqAPGmzSutPdK3MM1XNezy4bqwLI255rYjMguxmkJDJ6hYSzcozNy LS03HJEVkAeFGh+5wQN2e8WPTlPkbd0qNKk80JqD4jpoP2kBf43AD1MbRqmGG+OBLhJX 6l+zAmurAK9vw4+A81QCxsbvPmKOhFb/4Yii+LNG5LEcHhEBsaach8v91aKg8z+EtJ8W 9ylP53DSs5U7Tia7AD9Tm8zOVEbDwUmzif7vN+Vn1kKYhHraF3pkBftLT1JDk6NVvjWX bWGo/grt4yEw9uq2a7VxE1fXRCs2eZEUQAyxYPHmMtFR3RBYe5SpUwGC95H2yQpKeyzM kS+Q== X-Gm-Message-State: AOJu0YxUdJ+azpEkqV7qLJHDMzR9OD/43bLmvqojbOHzPN7IfSdMOi5Z csDVfU7ZcGnB42dxy7wb6K0Z6e3hs1gJa5OuiaBiqwRX2hRw+Iee6MbUh3E2rA== X-Gm-Gg: ASbGncuvdWHOTJ1Y83COcKrN/mYDuJiPH1pzOkZhEqjAkf6mnXCoTbaEOvxDgE0gFJt pVZHWWCJ0y8z8Tiu+X6curwKM6Yz8MaGB7QqWQGrn8w7+XtZjSz4xm+soaiVpUtUfDc+2FTVAcF q15Ih+FNY+6sDotKyepq1BKaAkqn7HUXeYJCPuIom9RCabbbKvJAzi1vbEi5To6TrsYXVpUAXBv pbt15t7uc2fDGMTTUT6o/SbcafgNaiJ9Vei0hZ2tiUTixuf4k7oyGjf5s1vhrKmU5nsL6lRkbNo kfyZ7qGHckuc1NVqlzFbv9q+crkQYy3ORdeHRPzL+SNjf6uB6777aXeWkmLEjf+B2H5wuGKBwb+ d3NzWHx1Jsiiey58y/QqRe0C6LXxS08YUmtsYCRvjDD/3FK2hDTP8+8KpQLvPAAmQVry3JeKfqj vbD0roidkFDskcp48t7f4bsQ== X-Google-Smtp-Source: AGHT+IHcWjJofCDdgdceqDEAsqHsvlHF6Q6KyOk3y64vGYnlqzNycPdkuosQ3RvbFFmw+oE+SqF/UQ== X-Received: by 2002:a05:6000:659:10b0:3a5:2dae:970f with SMTP id ffacd0b85a97d-3b5f1893c29mr3304479f8f.13.1752533345934; Mon, 14 Jul 2025 15:49:05 -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 v8 5/7] tools/libxl: Activate the altp2m_count feature Date: Mon, 14 Jul 2025 22:48:52 +0000 Message-Id: <5e6723a8f1f535e4948356ee24c33966116c84a9.1752531797.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: 1752533372021116600 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:56 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=1752533364; cv=none; d=zohomail.com; s=zohoarc; b=Pmc6p/RMSkfYlIB5dhQ5yL2sw9AYh7QP90apBcLgRgh2+W5wvcWTcHJuhK5dd0CiTO52GjiYGeERthyArqRdN0nIr0UEIgcr7sxLQrOgRL1vKpXTryE8m9TybYXsKMm/Z1432QHe1QaGh+ZXTkRhIALM4jrRq8PXr5gVFvUG30U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752533364; 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=FZwSbxRvG+z7BDul7RRlSizzRG+13bpwysVr99qXVmX9jPf8pnwoZ+HcbqAdk2SZ1Em6EyweQpL/jDpoJ0NNZN3axEgF920lHasCDitCJ1SXhQyHC8ZCdjXXzBIXH38gFVFzwG67GWHXs85gwmuCxLWvX0122Cud+YNTM22zfzU= 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 1752533364079253.74142975918278; Mon, 14 Jul 2025 15:49:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1043180.1413333 (Exim 4.92) (envelope-from ) id 1ubRyw-0005Q3-Dx; Mon, 14 Jul 2025 22:49:10 +0000 Received: by outflank-mailman (output) from mailman id 1043180.1413333; Mon, 14 Jul 2025 22:49:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubRyw-0005Pm-A5; Mon, 14 Jul 2025 22:49:10 +0000 Received: by outflank-mailman (input) for mailman id 1043180; Mon, 14 Jul 2025 22:49:08 +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 1ubRyu-00047A-4F for xen-devel@lists.xenproject.org; Mon, 14 Jul 2025 22:49:08 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bfe494a0-6104-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 00:49:07 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4535fc0485dso6184665e9.0 for ; Mon, 14 Jul 2025 15:49:07 -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 ffacd0b85a97d-3b5e8bd18ffsm13288903f8f.9.2025.07.14.15.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 15:49:06 -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: bfe494a0-6104-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752533347; x=1753138147; 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=CT0xK/VRPvLF9DlXfhh0fYneYEjkJU9MvXXGJDoyWlTXefzRPd1b2bNeQ0/2DWCu9B WZWQq9Di6Hfdoz4XvkoCnfbfoXBa5cugCplmktfn81IdLpLWF0IaeL13679DXks2Azeb K5BQK/FR/HE1+lJe61fdFk/WB5aaq69U0P6EqFj2vsa+6ZkXfQ4ouWGOkacpg4Tdnbq8 68jMGLLxogftxg0Y7Huwjt/Chun9+0tTufrWqVcMli/jyhLqF6Zk8QIMO0Q6LRKMktOZ 19RhFCSaCIyQ9ZILP/5zKLsz16ZkwuoKqVrTV7/A42M23dZoxoLbBgBDaoOCV6wU+8R3 fKWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752533347; x=1753138147; 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=acCiKrDgxh/9hCEk3QbA0llNst9+PTR4Wt+kuAd/PWD60oKdpcEdkRdlCpVZ/N0Fs0 cum4SeoeBe0GhBn+JYFKLYaPrscuWmSxiAq7sywRQ0hsFw2Fe+ON/lD902C0Up5YIjHZ lWWG5onD/gv4MbsyiUAG47iObF2X5NU2V+gOAuEUdqyKvLtRP54/JWMIFWPTPNGZ98Gw PEU8dMLshN4fw3Ng47Nlr5G2ceWWTK4Ya0KghTTH2Qo9YQaCuK9fqvQVs28u1nJLvMZU cC1S6ajVk/6b0ihp4BBcgmj1GmSFZ1myOhT5/8nriax9lTZnohYhWgnpm3zAbEY5ukw8 6EtA== X-Gm-Message-State: AOJu0YxubAtEgbk6nd7uVrKqrWMePAzxB03fCYwK64XjUx/ZHklmkddZ 8atiSRahkgjKIIS1TYXsk1fPB+AR5qphlFP7iHs2eYjaygm0HCiHvnAJOADG8g== X-Gm-Gg: ASbGncsYW3pRpS4K86XR3yYFFvRMTBBvU61MlIjbS4SOHtGRJS2a00psK7iklB6JY39 oV4MsSz6IFhTxTJwoazmsA/v5e1r9xOfLGzKHJ3HOH3CzdUlC/7ZIJaXdUBpm/8hptfZZYeP7np iSK9bjpndSYhlgClL8mmtLTAPoJQbVkGqtVtL8lh58SU6NtG1KxuBax9qnnzP72sQKtY6xb1K3+ EAkNer6T9nANdfuFtHKQuENC0jIw+8pp7CZEx01BLWCdjeE2j7fFXol9PHg7VKypzETMCdGgDnh CEYSuO0ichzj5XKkryxftprxSObI5JM2b7UjfPcRjUdISAtMY3hwApCPlxctLNuBWipvtH/Vn5V 9fZGwyG2wk8Ax4MzbgTTuf05BO3KPwKfHJZwQZ+oZfEJNcKFf70HHBaeBCXMJWTxADjSjS2VBr/ lBVJt0157ezExTPq0cmTlakQ== X-Google-Smtp-Source: AGHT+IHmWKQU6lUniaz21l7BAYPMklvfsfcW1ZxGsPJxx9MLKqe2Kg3PcisaukB/h4YssXGKwjiZdA== X-Received: by 2002:a05:6000:2908:b0:3a5:77ea:2d36 with SMTP id ffacd0b85a97d-3b5f2e4cf7amr4533746f8f.10.1752533346763; Mon, 14 Jul 2025 15:49:06 -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 v8 6/7] xen/x86: Disallow creating domains with altp2m enabled and altp2m.nr == 0 Date: Mon, 14 Jul 2025 22:48:53 +0000 Message-Id: <569006946c0586a6befba0062eaef96ff0d72c0c.1752531797.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: 1752533366038116600 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:56 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=1752533365; cv=none; d=zohomail.com; s=zohoarc; b=aFXyD2Cw4uh7fkj2s1rlIC9Dp+O2Tb1AyQf388TdG9rjKFiljnzFrNAQGolQEBzcGAySGb3lFN6hLlffzgjHJQfy5+0sTbq2B9IxIuOk232Sbr/20WppHAUUYL+tkPdJ/xj+KrlXFDwo5qg2rd+xPJ4PO42Cbxr/EXN8Km1LOBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752533365; 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=PHGUcfTpx4E/19lFF54vDWk1qHm4SNDvY97/Y0RE8Yug2nrY9sMLPgbdeBtFoeIL4Pnd1yXJN1hsSAcG567+ser+V2Mw7A3N9ROt7cdAGvZ1Oj2pbD0r8kySAdPtFtvrzH14g8xVFXQWFjfm/Wn5jAonojjMbBEzB50oKxkX7nI= 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 175253336593798.10770410545467; Mon, 14 Jul 2025 15:49:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1043182.1413344 (Exim 4.92) (envelope-from ) id 1ubRyx-0005Yg-6K; Mon, 14 Jul 2025 22:49:11 +0000 Received: by outflank-mailman (output) from mailman id 1043182.1413344; Mon, 14 Jul 2025 22:49:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubRyw-0005VF-Tu; Mon, 14 Jul 2025 22:49:10 +0000 Received: by outflank-mailman (input) for mailman id 1043182; Mon, 14 Jul 2025 22:49:09 +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 1ubRyv-00047A-BD for xen-devel@lists.xenproject.org; Mon, 14 Jul 2025 22:49:09 +0000 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [2a00:1450:4864:20::331]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c0948476-6104-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 00:49:08 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-456127b9958so2052035e9.3 for ; Mon, 14 Jul 2025 15:49:08 -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 ffacd0b85a97d-3b5e8bd18ffsm13288903f8f.9.2025.07.14.15.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 15:49:07 -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: c0948476-6104-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752533348; x=1753138148; 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=KAH5XJiUOS2m+hhQnfEbecb18ixsLk4zirKBSoTOBMcI3mdid1lit4HL6EdM8NFevH nk3PPYBtZOEKTNcaFpaqbw3jxRoffNlN0HgoxdkRV65msqfFgXm5TPQmlHyI5HEZMeTj dT+WaqALG+SDLhE8hqHnRdrCbQhTToIVIFLKKyplB3AzCt9BoQuhfa9DtAEc/beoSxZ1 K+/JOt5/m6WFfiz9nFbqRj+X+pmGJo18oQHHMPjCB73/cBHgW+Pf6570/iq8MiaFeiS3 /a4s1SSIh/ssOYfQNDGSxqJ02KtD3wiQuMIDRwQEGMQNlTx2V6LFUZ0En8i0EVQM82Dz oI6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752533348; x=1753138148; 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=D65F3ohq+JxkxDwmKqlVA8lyAiAY+EoZEEJjVb8+W9GJ90BPV8alK8LcnjtwtX3Ew7 x++NE+4Y6QADL/rjiL3auPkNgDU7Zwo7zp9/Hjjd9/JBIpq7gWH24Pymzfi2KZqp16pq daz25KAU+PUlEcpvElipprJ0E20tcW2plm+cd8/97nT/rbqGUy0XrAXxI6m4th/rvboX +0VCyaGNgSFi42UMhbd+nT1oWTwG7kOaf/gGu4JGCbstnGUQI6Q0yRh8gwD3f9BMB2M1 P68xZ+CmRybzwM3NSsBI1SpcNHOn49xVedglGnfKdaXUSD6dFqz6AAV9ARxoqORnw20a 6ZAw== X-Gm-Message-State: AOJu0YxWKgyTEvIm/9ekAYtO45MsIJOb89AoHihyLZGZhDtBoAGJFPQB ZQ0UtCUZojWHnqZlGFjADtWXNYTAR/yqBg08cEe01iWQxriofauAJ0V3wq82NQ== X-Gm-Gg: ASbGncsPy5R7bkyk75MA5F0RGhAzH6t7YTEyeysayJHQ/dLEt5o4wW1+sjJJYERxNNX 2K3f6rKwz1WQuZ8PR7yBAXFmaU5uMbCsw8tlQMfzJda6yYtojTVv9xi3aSrlupm0NDQ0ehsa/3E mUVkM/4Ah+j2Emuu8gs1whA8tJKjTjsEKhNeQ7OaiZ2lUtf+Xe1/q9B/aIRpwhi/19axcyIgcjY h2Q2BO1pLy31aQj4zreoNud/NhFFdF02S59Ws7RZkleYhX+XouqNDT24aM8ELchWZ3OTpokqbsb IGet9Fy3FblwTecBFDV5QkrGr8vpjiGodLRyVw6cILcjJlE2mW62biCsK8GypFqa5CDexRvyJMG sQenWrKWKutcJQWgJyr8HDcIkHjodMHo0sR5hIKD702ZurFO8q2CLCsYX8KJb3XSJhRYvN1fUR3 nT3fu+sy1idv2NYNry7K2pyQ== X-Google-Smtp-Source: AGHT+IHpDe3FwxEXdNxozTuNftQFcweEjIQ3h3y/go7BeUg7Dya7iNxrhwZ+e/DzbwrPgQjzLKTiog== X-Received: by 2002:a05:6000:1ac6:b0:3a4:e193:e6e7 with SMTP id ffacd0b85a97d-3b5f2df1b4amr4175538f8f.5.1752533347621; Mon, 14 Jul 2025 15:49:07 -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 v8 7/7] tools/ocaml: Add altp2m_count parameter Date: Mon, 14 Jul 2025 22:48:54 +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: 1752533367932116600 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