From nobody Thu Oct 30 18:55:07 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=1753871963; cv=none; d=zohomail.com; s=zohoarc; b=Pf0jfEpWPgFkpFNGbQyCc2briP01F1TJhCYvj7p3Mkpy72DdEvxiy8eo0DpS6h2HZqxotCieXSFzCQSS8xSqc97DfJxEi3+yzEHRAJx5feN9rs2N2UX+wbQNE4pDye0O/QHGPBwu4E3nUlIZuDKdU9mpXJ6mSePvy2ofqNqIinY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753871963; 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=Fs7immBpsjg/CC1c0NrPQ+GJ1vwL40420mXoAA5WNDg=; b=JiohKt8vlDFaozikhFAEQdf9KtRMZFZE4OWUIA0cDjwwQBWuAIi6xo/4xW5Bm+CnupbZScdmKaXFQ0bcaCp8IsEs/yPZAr8MP8cI8pyv0inpbWIkIRxBR7qaHhQGYAetjsg6ggwQqvBOhKxL39/6l9WwJRoG+K819gcGIm6sGm0= 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 1753871963574872.5585883257472; Wed, 30 Jul 2025 03:39:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063727.1429453 (Exim 4.92) (envelope-from ) id 1uh4D9-00088x-70; Wed, 30 Jul 2025 10:39:03 +0000 Received: by outflank-mailman (output) from mailman id 1063727.1429453; Wed, 30 Jul 2025 10:39:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uh4D9-00088q-2r; Wed, 30 Jul 2025 10:39:03 +0000 Received: by outflank-mailman (input) for mailman id 1063727; Wed, 30 Jul 2025 10:39: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 1uh4D8-0007vS-7b for xen-devel@lists.xenproject.org; Wed, 30 Jul 2025 10:39:02 +0000 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [2a00:1450:4864:20::629]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 672e308e-6d31-11f0-b895-0df219b8e170; Wed, 30 Jul 2025 12:39:00 +0200 (CEST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-af8ed6ae8c4so32262866b.1 for ; Wed, 30 Jul 2025 03:39:00 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-af8f1b17364sm183230166b.66.2025.07.30.03.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 03:38:58 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 672e308e-6d31-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753871939; x=1754476739; 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=Fs7immBpsjg/CC1c0NrPQ+GJ1vwL40420mXoAA5WNDg=; b=CY6cPzsx3L/4+wxlvr0nQ2Qm+puTvDdcETe6c4b7cWO+6CF04+WkiRfasbYVkDteKt GWBV/81pXhUvfn3ez4n3tvLwXwdh8vSWNS1Wq3XtpJAmxq3+3LIQTfD/6SqAWi/KoAMb 1K878zZn1f3uFKZJGuBLNzN4eGyTC+t0X20s4C1p+VzOqz3QuXCyFmD1wwgZE3+md4wH 2yrHPHBWj6lOrQ+wy3sh5ha/ANQU3EkkJ5/bVV+vfKliSLIIrlfrVLq55RxuA3BNpvRj 47RZhZ9OOouZgky5ELk2W90E2+OB3sABVZxuVBMMNnGWbWrgUcOuahwCoEJTmJxG2Cu1 xvag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753871939; x=1754476739; 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=Fs7immBpsjg/CC1c0NrPQ+GJ1vwL40420mXoAA5WNDg=; b=ffocWNnJmnx2s6vJTKHP8ud3a+BWphfQJdx6MegV8SUZNo64FQIQovFY4maUyKkBRA 2fCfmesdAVfyf/YYn6Y6/u31wXXwfMr2O5pXP9+EXX3ZMiZAXnVbPUxxGZQa9PPe9M74 Jw0aedQnDO7fKQ1ysgjmivc7fHeXzvFrBacQkVmMZXdKXkeVxMlOpM7BN9UFA3AoBheE jHBMKghE+UNPT9//5MjlCvozQeTkosEU0z7C2zE13MdIxih9GCRKXaxMJrAyL2LAxBhd fRabuacb3OlEvWtl4LrqS81klAapHTF1+HGf1hcXHU1SRGWMtVf7gTvH3xqPcd5NwoLQ vIxg== X-Gm-Message-State: AOJu0YzfKSKM9dhnBFSaCcpP/X9IcaGT4LFh7ecMEZvWPX86qXPC040X KvKYnRM/StNh+K+SzKwRWWRcvRni2UiHUjK9Zficsl65TzTDTSDm+jAfOj9JI3Td48I= X-Gm-Gg: ASbGnctVMBwRVlBozpCwj9bvRjnBNCGp70oahX8MYBEiwGXY+veFsR6P+pJb0RIgQMS rtbCgEmyUnctL4q4+N7mu9gUlLcU3lZ5oay5/ZHRF+M+cFO2KQFQgn4sfscUiXecA4PDPeedHz4 UcsbJj6NKOZC9sQ3jbAHHVJMMgmhXLRTJLAW1B/JVzJKpjsndR2KTMxEokRM2Uzn2d/Xvxo96VQ PmJhf6/vphsertmeBAg4pozcGkOvLF/x7RRrq8SwTKVTgL4JltJRN9nE6PO4qFQ9pGFdbx6u5Zq LzHIJgqCdc82+GKsgk43JMmUx/qHo4FflgBP2i6xP1rB5Mw2/PGbi6KKJAbxZNwMQXbtAKvBuMI gOcrolZ9dFeWxvS0K/+A/u9igwAsy/ukn7UWO825bt4AWyI9AvT5CiQABYK/V3gWc24GKzNE/sR GvcYWdIeoA9rPAZbwbTuab3A== X-Google-Smtp-Source: AGHT+IFno4gD5Y7pvle2bN5tEJvlNS3/nYgVwaIf2nbxvuDWeKRZdpgVfDgukn+beZvtPJz8RDrPOA== X-Received: by 2002:a17:907:3f16:b0:ae0:bb1a:8c4 with SMTP id a640c23a62f3a-af8fd69c0bcmr126204766b.1.1753871939112; Wed, 30 Jul 2025 03:38:59 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Shawn Anastasio , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu Subject: [PATCH v11 1/6] altp2m: Drop p2m_altp2m_check() stubs on non-x86, move prototype, and guard uses Date: Wed, 30 Jul 2025 10:38:45 +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: 1753871965999116600 From: Petr Bene=C5=A1 Remove the no=E2=80=91op stubs from the ARM, PPC, and RISC=E2=80=91V p2m he= aders and stop providing a stub in arch/x86/include/asm/p2m.h. Declare p2m_altp2m_check() in xen/include/xen/p2m-common.h and gate all call sites with CONFIG_ALTP2M: - wrap the fast_single_step block in hvm/monitor.c with #ifdef CONFIG_ALTP= 2M (IS_ENABLED(CONFIG_ALTP2M) is not used here, because in the following co= mmit hvm_vcpu::fast_single_step will be guarded by CONFIG_ALTP2M) - make the vm_event.c path conditional via IS_ENABLED(CONFIG_ALTP2M) No functional change intended: on builds without ALTP2M the calls are compiled out; on builds with ALTP2M behavior is unchanged. Signed-off-by: Petr Bene=C5=A1 Reviewed-by: Jan Beulich --- xen/arch/arm/include/asm/p2m.h | 6 ------ xen/arch/ppc/include/asm/p2m.h | 5 ----- xen/arch/riscv/include/asm/p2m.h | 5 ----- xen/arch/x86/hvm/monitor.c | 2 ++ xen/arch/x86/include/asm/p2m.h | 8 +------- xen/common/vm_event.c | 3 ++- xen/include/xen/p2m-common.h | 3 +++ 7 files changed, 8 insertions(+), 24 deletions(-) diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h index 2d53bf9b61..ef98bc5f4d 100644 --- a/xen/arch/arm/include/asm/p2m.h +++ b/xen/arch/arm/include/asm/p2m.h @@ -180,12 +180,6 @@ static inline bool arch_acquire_resource_check(struct = domain *d) return true; } =20 -static inline -void p2m_altp2m_check(struct vcpu *v, uint16_t idx) -{ - /* Not supported on ARM. */ -} - /* * Helper to restrict "p2m_ipa_bits" according the external entity * (e.g. IOMMU) requirements. diff --git a/xen/arch/ppc/include/asm/p2m.h b/xen/arch/ppc/include/asm/p2m.h index f144ef8e1a..c96149ef74 100644 --- a/xen/arch/ppc/include/asm/p2m.h +++ b/xen/arch/ppc/include/asm/p2m.h @@ -88,9 +88,4 @@ static inline bool arch_acquire_resource_check(struct dom= ain *d) return false; } =20 -static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) -{ - /* Not supported on PPC. */ -} - #endif /* __ASM_PPC_P2M_H__ */ diff --git a/xen/arch/riscv/include/asm/p2m.h b/xen/arch/riscv/include/asm/= p2m.h index 28f57a74f2..e43c559e0c 100644 --- a/xen/arch/riscv/include/asm/p2m.h +++ b/xen/arch/riscv/include/asm/p2m.h @@ -88,11 +88,6 @@ static inline bool arch_acquire_resource_check(struct do= main *d) return false; } =20 -static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) -{ - /* Not supported on RISCV. */ -} - #endif /* ASM__RISCV__P2M_H */ =20 /* diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c index 523586ca98..d22a2e4644 100644 --- a/xen/arch/x86/hvm/monitor.c +++ b/xen/arch/x86/hvm/monitor.c @@ -178,6 +178,7 @@ int hvm_monitor_debug(unsigned long rip, enum hvm_monit= or_debug_type type, break; =20 case HVM_MONITOR_SINGLESTEP_BREAKPOINT: +#ifdef CONFIG_ALTP2M if ( curr->arch.hvm.fast_single_step.enabled ) { p2m_altp2m_check(curr, curr->arch.hvm.fast_single_step.p2midx); @@ -186,6 +187,7 @@ int hvm_monitor_debug(unsigned long rip, enum hvm_monit= or_debug_type type, curr->arch.hvm.fast_single_step.p2midx =3D 0; return 0; } +#endif if ( !ad->monitor.singlestep_enabled ) return 0; req.reason =3D VM_EVENT_REASON_SINGLESTEP; diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 58b56e575e..c53f4e487d 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -962,17 +962,11 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn= _t gfn, /* Set a specific p2m view visibility */ int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int altp2m_i= dx, uint8_t visible); + #else /* !CONFIG_HVM */ struct p2m_domain *p2m_get_altp2m(struct vcpu *v); #endif /* CONFIG_HVM */ =20 -#ifdef CONFIG_ALTP2M -/* Check to see if vcpu should be switched to a different p2m. */ -void p2m_altp2m_check(struct vcpu *v, uint16_t idx); -#else -static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) {} -#endif - /* p2m access to IOMMU flags */ static inline unsigned int p2m_access_to_iommu_flags(p2m_access_t p2ma) { diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 1666ff615f..b2787c0108 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -431,7 +431,8 @@ static int vm_event_resume(struct domain *d, struct vm_= event_domain *ved) vm_event_toggle_singlestep(d, v, &rsp); =20 /* Check for altp2m switch */ - if ( rsp.flags & VM_EVENT_FLAG_ALTERNATE_P2M ) + if ( IS_ENABLED(CONFIG_ALTP2M) && + rsp.flags & VM_EVENT_FLAG_ALTERNATE_P2M ) p2m_altp2m_check(v, rsp.altp2m_idx); =20 if ( rsp.flags & VM_EVENT_FLAG_SET_REGISTERS ) diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h index a322e738ef..f0bd9a6b98 100644 --- a/xen/include/xen/p2m-common.h +++ b/xen/include/xen/p2m-common.h @@ -24,6 +24,9 @@ int unmap_mmio_regions(struct domain *d, unsigned long nr, mfn_t mfn); =20 +/* Check to see if vcpu should be switched to a different p2m. */ +void p2m_altp2m_check(struct vcpu *v, uint16_t idx); + /* * Populate-on-Demand */ --=20 2.34.1 From nobody Thu Oct 30 18:55:07 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=1753871963; cv=none; d=zohomail.com; s=zohoarc; b=CsrxCkaUP+BOIBQgpgFPGFqX7ZZ1EzjJEF49hwdKYs04Wqw8z3o9p6thuN7PFXKhanm9942b2Pgl7+egfx3I70a6uFWFkA+PwL16sKVUhsXybEJAMDj2YU09TdDsSrHr7HPvbyBWZA1M1+Lv65m82oLDWebcpKX5toIe6AtnI2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753871963; 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=ioDaCChKtLWr9K4px+ID0VBnInJgvmwLcCt2K4+hRi0=; b=h5aIu19UI+1VHyfZpNL2gppExX2k3dcQFfVwJZ/IMgw5CzBCtKQHidmr+iCrjP3gmJMIwkJ41bhqiVkUgay6xV4fNy7bJD8GROp2XhOxq1IBCoVONTGefSdo4vjI3qx8qgKxrMooDgDVXLUPlQcysMDLqcoh1rwjVpa8FTgb8F4= 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 1753871963848539.9852428376824; Wed, 30 Jul 2025 03:39:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063728.1429463 (Exim 4.92) (envelope-from ) id 1uh4DA-0008Ml-Cb; Wed, 30 Jul 2025 10:39:04 +0000 Received: by outflank-mailman (output) from mailman id 1063728.1429463; Wed, 30 Jul 2025 10:39: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 1uh4DA-0008Me-9i; Wed, 30 Jul 2025 10:39:04 +0000 Received: by outflank-mailman (input) for mailman id 1063728; Wed, 30 Jul 2025 10:39: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 1uh4D9-0007vS-6U for xen-devel@lists.xenproject.org; Wed, 30 Jul 2025 10:39:03 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 67ea21d0-6d31-11f0-b895-0df219b8e170; Wed, 30 Jul 2025 12:39:01 +0200 (CEST) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-af240271376so73440766b.2 for ; Wed, 30 Jul 2025 03:39: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 a640c23a62f3a-af8f1b17364sm183230166b.66.2025.07.30.03.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 03:38: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: 67ea21d0-6d31-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753871940; x=1754476740; 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=ioDaCChKtLWr9K4px+ID0VBnInJgvmwLcCt2K4+hRi0=; b=elRYXYLU88/YJgZdoRtStbTVjB56EnYrAPdkCf5hlDlYCIP5H9aVwssDC9GKBDZ8aV MuWOgWVSdVlcCL8P21Cs9H+0FFQV74TfiDcTkKaM4f3W7JpkErCN238eM1+ytPXaGI8n ZCWk8Zunau7UlvMp2aW1S78EC0iICdS9zWZcM4nSx6oexLWoiu9cMIFTcKL2v+NGHx6I YMOfcLyQHHdFNDsYkzNWk9D/5c4D4Rivy9wXTFWo60RRt/1sR2qvG56EAxqNxuefJx2g rHJlV2CwhLGwFoDKVv+y51pi5MRL2ncK9gzOZSrk5pYw622ZVNQuw3QMxtFDWUMqnXs2 xE0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753871940; x=1754476740; 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=ioDaCChKtLWr9K4px+ID0VBnInJgvmwLcCt2K4+hRi0=; b=BlIxALSPM9eyyRayjCLHGY+0uh42/eDGaRHG4aukQxGD5MC4Kn/05SQlZIj+W/IKZ+ EIeY+Inafyx0sjzEnFR+ivwsUwakcFwGXQdI+LdAtTSlkzRVllxoDrp1Mqd6hU4EwKFE 0fpaecOxS9x9FAkqvT5Ajdr5VWIT5eMaH7EnqdKYzY2YFqBy2jOwArNCaYpG3wJSxnwB xgWKJHKel92v1yOdfdeYSIDo0mDFDakKXdhKBq1zbB09v1kE4dK7mHeZJ+Kz+bqLyEla 462/UCVz8b6ahj/Be8oInIs4WRtCokKm2SX7jUtLCtpeo9r78uHQUXl9PNvbpAHYs04h FFVQ== X-Gm-Message-State: AOJu0YwbRwBEHMXKOido5Zc04ghXUziVx+iU/1yzBdioPcjzvZRDP15k glKGMSmkoiUkUv4kiPXdih/sdcDlzE7wFT87yDfdvZszjwmhmrigZPmEclnunyzYdrE= X-Gm-Gg: ASbGncsU3+4D0aaARNqpLx3mqhmC89mj6gHhg16y4exhEzM8BNvCpXX58Geq/ti0j9E 4xzH508U1uwGQ1TAttzjVVTFOPanPc3Dt3GdBMnbGcaVnR3xbFccfuXokNpMGvneV6DOK2phjHx 7EEA6BHx6fw/O28TbyXvshkUOk9xb8JPdHctcCgsz8iFgCNjAua/U1p2BO7e2MQXGgIsSV7mrSG /wA9zPsN0MhupQMoWp0865ohBNluGWduCO5FpYuIPt0InL8XR6XhLg9d06PLI//JY2wPQoDcZEz 4oWOtb2QFNS/QEgYts7Kqnc8ljDJnIqZQkM+cNbjGFq1htOBd/qzSD4HmVrVg16gHuOPQ7i4oQE 04WRJrDEzVKALV+x3GkKG+SWnySAaYdcNGU69cwKgJBf3nO4R57ZHHJqjZlV9HB4YEyHyixS1hw YU4JARWJbtLeRlPa1VRtSs8g== X-Google-Smtp-Source: AGHT+IEGDIV/rkWTD8Zow9nCzJ3dWaUDUWUqe8p6oEND37DTWRVBBE5t3LHKQDaD05w8ueXvC6VJ/A== X-Received: by 2002:a17:907:9691:b0:af6:32b3:2674 with SMTP id a640c23a62f3a-af8fd2f97aamr140400966b.0.1753871940140; Wed, 30 Jul 2025 03:39: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?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu Subject: [PATCH v11 2/6] x86/altp2m: Wrap altp2m-specific code in #ifdef CONFIG_ALTP2M Date: Wed, 30 Jul 2025 10:38:46 +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: 1753871966155116600 From: Petr Bene=C5=A1 This change consistently guards all altp2m-related functionality behind #ifdef CONFIG_ALTP2M, so that code and data structures related to alternate p2m views are only included when the feature is enabled. Apart from that: - hvmemul_vmfunc() returns X86EMUL_UNHANDLEABLE when altp2m is disabled. - do_altp2m_op() returns EOPNOTSUPP when altp2m is disabled. - struct hvm_vcpu, arch_domain, and hvm_function_table only define altp2m fields when the feature is enabled. - Moved several declarations under #ifdef CONFIG_ALTP2M in p2m.h to avoid polluting builds that don't require the feature. Signed-off-by: Petr Bene=C5=A1 --- xen/arch/x86/hvm/emulate.c | 4 ++++ xen/arch/x86/hvm/hvm.c | 10 ++++++++++ xen/arch/x86/hvm/vmx/vmx.c | 8 ++++++++ xen/arch/x86/include/asm/domain.h | 2 ++ xen/arch/x86/include/asm/hvm/hvm.h | 6 ++++++ xen/arch/x86/include/asm/hvm/vcpu.h | 4 ++++ xen/arch/x86/include/asm/p2m.h | 12 ++++++++++++ xen/arch/x86/mm/hap/hap.c | 6 ++++++ xen/arch/x86/mm/mem_access.c | 8 ++++++++ xen/arch/x86/mm/p2m-ept.c | 4 ++++ xen/arch/x86/mm/p2m.c | 9 +++++++++ xen/arch/x86/vm_event.c | 2 +- 12 files changed, 74 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index f1412d8c49..2af4f30359 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -2704,6 +2704,7 @@ static int cf_check hvmemul_tlb_op( static int cf_check hvmemul_vmfunc( struct x86_emulate_ctxt *ctxt) { +#ifdef CONFIG_ALTP2M int rc; =20 if ( !hvm_funcs.altp2m_vcpu_emulate_vmfunc ) @@ -2713,6 +2714,9 @@ static int cf_check hvmemul_vmfunc( x86_emul_hw_exception(X86_EXC_UD, X86_EVENT_NO_EC, ctxt); =20 return rc; +#else + return X86EMUL_UNHANDLEABLE; +#endif } =20 static const struct x86_emulate_ops hvm_emulate_ops =3D { diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 56c7de3977..1881c8ac52 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4608,6 +4608,7 @@ static int hvmop_get_param( static int do_altp2m_op( XEN_GUEST_HANDLE_PARAM(void) arg) { +#ifdef CONFIG_ALTP2M struct xen_hvm_altp2m_op a; struct domain *d =3D NULL; int rc =3D 0; @@ -4944,6 +4945,9 @@ static int do_altp2m_op( rcu_unlock_domain(d); =20 return rc; +#else /* !CONFIG_ALTP2M */ + return -EOPNOTSUPP; +#endif /* CONFIG_ALTP2M */ } =20 DEFINE_XEN_GUEST_HANDLE(compat_hvm_altp2m_op_t); @@ -5235,8 +5239,12 @@ int hvm_debug_op(struct vcpu *v, int32_t op) =20 case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF: v->arch.hvm.single_step =3D false; + +#ifdef CONFIG_ALTP2M v->arch.hvm.fast_single_step.enabled =3D false; v->arch.hvm.fast_single_step.p2midx =3D 0; +#endif + break; =20 default: /* Excluded above */ @@ -5259,6 +5267,7 @@ void hvm_toggle_singlestep(struct vcpu *v) v->arch.hvm.single_step =3D !v->arch.hvm.single_step; } =20 +#ifdef CONFIG_ALTP2M void hvm_fast_singlestep(struct vcpu *v, uint16_t p2midx) { ASSERT(atomic_read(&v->pause_count)); @@ -5273,6 +5282,7 @@ void hvm_fast_singlestep(struct vcpu *v, uint16_t p2m= idx) v->arch.hvm.fast_single_step.enabled =3D true; v->arch.hvm.fast_single_step.p2midx =3D p2midx; } +#endif =20 /* * Segment caches in VMCB/VMCS are inconsistent about which bits are check= ed, diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index ce538668c7..64f0dbbd4a 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2416,6 +2416,8 @@ static void cf_check vmx_enable_msr_interception(stru= ct domain *d, uint32_t msr) vmx_set_msr_intercept(v, msr, VMX_MSR_W); } =20 +#ifdef CONFIG_ALTP2M + static void cf_check vmx_vcpu_update_eptp(struct vcpu *v) { struct domain *d =3D v->domain; @@ -2535,6 +2537,8 @@ static bool cf_check vmx_vcpu_emulate_ve(struct vcpu = *v) return rc; } =20 +#endif /* CONFIG_ALTP2M */ + static bool cf_check vmx_get_pending_event( struct vcpu *v, struct x86_event *info) { @@ -2863,10 +2867,12 @@ static struct hvm_function_table __initdata_cf_clob= ber vmx_function_table =3D { .update_vlapic_mode =3D vmx_vlapic_msr_changed, .nhvm_hap_walk_L1_p2m =3D nvmx_hap_walk_L1_p2m, .enable_msr_interception =3D vmx_enable_msr_interception, +#ifdef CONFIG_ALTP2M .altp2m_vcpu_update_p2m =3D vmx_vcpu_update_eptp, .altp2m_vcpu_update_vmfunc_ve =3D vmx_vcpu_update_vmfunc_ve, .altp2m_vcpu_emulate_ve =3D vmx_vcpu_emulate_ve, .altp2m_vcpu_emulate_vmfunc =3D vmx_vcpu_emulate_vmfunc, +#endif .vmtrace_control =3D vmtrace_control, .vmtrace_output_position =3D vmtrace_output_position, .vmtrace_set_option =3D vmtrace_set_option, @@ -4963,6 +4969,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_u= ser_regs *regs) single =3D ept; } =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(currd) ) { unsigned int i; @@ -4981,6 +4988,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_u= ser_regs *regs) } } } +#endif =20 if ( inv ) __invept(inv =3D=3D 1 ? INVEPT_SINGLE_CONTEXT : INVEPT_ALL_CON= TEXT, diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index 8c0dea12a5..8749c5eba0 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -351,12 +351,14 @@ struct arch_domain struct p2m_domain *nested_p2m[MAX_NESTEDP2M]; mm_lock_t nested_p2m_lock; =20 +#ifdef CONFIG_ALTP2M /* altp2m: allow multiple copies of host p2m */ bool altp2m_active; struct p2m_domain *altp2m_p2m[MAX_ALTP2M]; mm_lock_t altp2m_list_lock; uint64_t *altp2m_eptp; uint64_t *altp2m_visible_eptp; +#endif #endif =20 /* NB. protected by d->event_lock and by irq_desc[irq].lock */ diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/= hvm/hvm.h index bf8bc2e100..e94cfbfb58 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -225,11 +225,13 @@ struct hvm_function_table { =20 void (*enable_msr_interception)(struct domain *d, uint32_t msr); =20 +#ifdef CONFIG_ALTP2M /* Alternate p2m */ void (*altp2m_vcpu_update_p2m)(struct vcpu *v); void (*altp2m_vcpu_update_vmfunc_ve)(struct vcpu *v); bool (*altp2m_vcpu_emulate_ve)(struct vcpu *v); int (*altp2m_vcpu_emulate_vmfunc)(const struct cpu_user_regs *regs); +#endif =20 /* vmtrace */ int (*vmtrace_control)(struct vcpu *v, bool enable, bool reset); @@ -707,6 +709,7 @@ static inline bool hvm_nested_virt_supported(void) return hvm_funcs.caps.nested_virt; } =20 +#ifdef CONFIG_ALTP2M /* updates the current hardware p2m */ static inline void altp2m_vcpu_update_p2m(struct vcpu *v) { @@ -731,6 +734,9 @@ static inline bool altp2m_vcpu_emulate_ve(struct vcpu *= v) } return false; } +#else /* !CONFIG_ALTP2M */ +bool altp2m_vcpu_emulate_ve(struct vcpu *v); +#endif /* CONFIG_ALTP2M */ =20 static inline int hvm_vmtrace_control(struct vcpu *v, bool enable, bool re= set) { diff --git a/xen/arch/x86/include/asm/hvm/vcpu.h b/xen/arch/x86/include/asm= /hvm/vcpu.h index 196fed6d5d..924af890c5 100644 --- a/xen/arch/x86/include/asm/hvm/vcpu.h +++ b/xen/arch/x86/include/asm/hvm/vcpu.h @@ -133,10 +133,12 @@ struct hvm_vcpu { bool flag_dr_dirty; bool debug_state_latch; bool single_step; +#ifdef CONFIG_ALTP2M struct { bool enabled; uint16_t p2midx; } fast_single_step; +#endif =20 /* (MFN) hypervisor page table */ pagetable_t monitor_table; @@ -154,7 +156,9 @@ struct hvm_vcpu { =20 struct nestedvcpu nvcpu; =20 +#ifdef CONFIG_ALTP2M struct altp2mvcpu avcpu; +#endif =20 struct mtrr_state mtrr; u64 pat_cr; diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index c53f4e487d..6ead4891a4 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -889,6 +889,8 @@ void shadow_p2m_init(struct p2m_domain *p2m); void cf_check nestedp2m_write_p2m_entry_post( struct p2m_domain *p2m, unsigned int oflags); =20 +#ifdef CONFIG_ALTP2M + /* * Alternate p2m: shadow p2m tables used for alternate memory views */ @@ -965,6 +967,16 @@ int p2m_set_altp2m_view_visibility(struct domain *d, u= nsigned int altp2m_idx, =20 #else /* !CONFIG_HVM */ struct p2m_domain *p2m_get_altp2m(struct vcpu *v); +bool p2m_set_altp2m(struct vcpu *v, unsigned int idx); +bool p2m_altp2m_get_or_propagate(struct p2m_domain *ap2m, unsigned long gf= n_l, + mfn_t *mfn, p2m_type_t *p2mt, + p2m_access_t *p2ma, unsigned int *page_or= der); +int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn, + mfn_t mfn, unsigned int page_order, + p2m_type_t p2mt, p2m_access_t p2ma); + +#endif /* CONFIG_ALTP2M */ + #endif /* CONFIG_HVM */ =20 /* p2m access to IOMMU flags */ diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index ec5043a8aa..384c24028f 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -494,6 +494,7 @@ int hap_enable(struct domain *d, u32 mode) goto out; } =20 +#ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() ) { /* Init alternate p2m data */ @@ -524,6 +525,7 @@ int hap_enable(struct domain *d, u32 mode) =20 d->arch.altp2m_active =3D false; } +#endif /* CONFIG_ALTP2M */ =20 /* Now let other users see the new mode */ d->arch.paging.mode =3D mode | PG_HAP_enable; @@ -537,9 +539,11 @@ void hap_final_teardown(struct domain *d) { unsigned int i; =20 +#ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() ) for ( i =3D 0; i < MAX_ALTP2M; i++ ) p2m_teardown(d->arch.altp2m_p2m[i], true, NULL); +#endif =20 /* Destroy nestedp2m's first */ for (i =3D 0; i < MAX_NESTEDP2M; i++) { @@ -578,6 +582,7 @@ void hap_teardown(struct domain *d, bool *preempted) for_each_vcpu ( d, v ) hap_vcpu_teardown(v); =20 +#ifdef CONFIG_ALTP2M /* Leave the root pt in case we get further attempts to modify the p2m= . */ if ( hvm_altp2m_supported() ) { @@ -597,6 +602,7 @@ void hap_teardown(struct domain *d, bool *preempted) return; } } +#endif =20 /* Destroy nestedp2m's after altp2m. */ for ( i =3D 0; i < MAX_NESTEDP2M; i++ ) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 21b5b7ecda..0779c41161 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -347,6 +347,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, ui= nt32_t nr, unsigned long gfn_l; long rc =3D 0; =20 +#ifdef CONFIG_ALTP2M /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { @@ -357,6 +358,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, ui= nt32_t nr, =20 ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 if ( !xenmem_access_to_p2m_access(p2m, access, &a) ) return -EINVAL; @@ -403,6 +405,7 @@ long p2m_set_mem_access_multi(struct domain *d, struct p2m_domain *p2m =3D p2m_get_hostp2m(d), *ap2m =3D NULL; long rc =3D 0; =20 +#ifdef CONFIG_ALTP2M /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { @@ -413,6 +416,7 @@ long p2m_set_mem_access_multi(struct domain *d, =20 ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 p2m_lock(p2m); if ( ap2m ) @@ -462,6 +466,7 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xen= mem_access_t *access, { struct p2m_domain *p2m =3D p2m_get_hostp2m(d); =20 +#ifdef CONFIG_ALTP2M if ( !altp2m_active(d) ) { if ( altp2m_idx ) @@ -476,6 +481,7 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xen= mem_access_t *access, =20 p2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 return _p2m_get_mem_access(p2m, gfn, access); } @@ -486,6 +492,7 @@ void arch_p2m_set_access_required(struct domain *d, boo= l access_required) =20 p2m_get_hostp2m(d)->access_required =3D access_required; =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(d) ) { unsigned int i; @@ -497,6 +504,7 @@ void arch_p2m_set_access_required(struct domain *d, boo= l access_required) p2m->access_required =3D access_required; } } +#endif } =20 bool p2m_mem_access_sanity_check(const struct domain *d) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 62fc8e5068..ae262bfcc2 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1297,6 +1297,7 @@ static void ept_set_ad_sync(struct domain *d, bool va= lue) =20 hostp2m->ept.ad =3D value; =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -1315,6 +1316,7 @@ static void ept_set_ad_sync(struct domain *d, bool va= lue) p2m_unlock(p2m); } } +#endif } =20 static void ept_enable_pml(struct p2m_domain *p2m) @@ -1571,6 +1573,7 @@ void __init setup_ept_dump(void) register_keyhandler('D', ept_dump_p2m_table, "dump VT-x EPT tables", 0= ); } =20 +#ifdef CONFIG_ALTP2M void p2m_init_altp2m_ept(struct domain *d, unsigned int i) { struct p2m_domain *p2m =3D array_access_nospec(d->arch.altp2m_p2m, i); @@ -1610,6 +1613,7 @@ unsigned int p2m_find_altp2m_by_eptp(struct domain *d= , uint64_t eptp) altp2m_list_unlock(d); return i; } +#endif /* CONFIG_ALTP2M */ =20 /* * Local variables: diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index b9a7c2dc53..5a3fda903e 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -101,6 +101,7 @@ void p2m_change_entry_type_global(struct domain *d, =20 change_entry_type_global(hostp2m, ot, nt); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -117,6 +118,7 @@ void p2m_change_entry_type_global(struct domain *d, } } } +#endif =20 p2m_unlock(hostp2m); } @@ -145,6 +147,7 @@ bool p2m_memory_type_changed(struct domain *d) =20 _memory_type_changed(hostp2m); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -161,6 +164,7 @@ bool p2m_memory_type_changed(struct domain *d) } } } +#endif =20 p2m_unlock(hostp2m); =20 @@ -930,6 +934,7 @@ void p2m_change_type_range(struct domain *d, =20 change_type_range(hostp2m, start, end, ot, nt); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -946,6 +951,8 @@ void p2m_change_type_range(struct domain *d, } } } +#endif + hostp2m->defer_nested_flush =3D false; if ( nestedhvm_enabled(d) ) p2m_flush_nestedp2m(d); @@ -1003,6 +1010,7 @@ int p2m_finish_type_change(struct domain *d, if ( rc < 0 ) goto out; =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -1022,6 +1030,7 @@ int p2m_finish_type_change(struct domain *d, } } } +#endif =20 out: p2m_unlock(hostp2m); diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c index 0d15d363c3..fc349270b9 100644 --- a/xen/arch/x86/vm_event.c +++ b/xen/arch/x86/vm_event.c @@ -72,7 +72,7 @@ void vm_event_toggle_singlestep(struct domain *d, struct = vcpu *v, =20 if ( rsp->flags & VM_EVENT_FLAG_TOGGLE_SINGLESTEP ) hvm_toggle_singlestep(v); - else + else if ( IS_ENABLED(CONFIG_ALTP2M) ) hvm_fast_singlestep(v, rsp->u.fast_singlestep.p2midx); } =20 --=20 2.34.1 From nobody Thu Oct 30 18:55:07 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=1753871958; cv=none; d=zohomail.com; s=zohoarc; b=DkoRIcz1mjrS5zsQqb3mDZQzZrNe0uFoHf4GFFh93WykYG3K7F1Ltf3OvLygAkHxcJKPHVdaY8K1PobYDGFiten8uVyEyQxhnHfFnJ2EIsvEUWdQ3EQ+GQYQKyiy7FDSUTJrOoWC9xau600Z0/aqAA4wuxsjJkz41xggK+wKVrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753871958; 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=wsgRhZe0m3cfqTt4t1L2u+vUAFJZc+UMkUbqgwGoE0Q=; b=mS5qXKh3EqnPkTe/8Nw4K0bQQtIFPTuQhHwJNo/yvA44gSSBKz6YN5osNj4t4UXZmqYTKVfzknAYepX1qUb+7YGWpQ2sLJBcD7D3Tyvs082iolR8UUPEHtr0MzyMYYzkqIzgUQqsRfcvFKcqGHAPk1tEanT0GMKAlMLD9BV8XS4= 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 1753871958625505.489098198928; Wed, 30 Jul 2025 03:39:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063729.1429473 (Exim 4.92) (envelope-from ) id 1uh4DB-0000Am-PI; Wed, 30 Jul 2025 10:39:05 +0000 Received: by outflank-mailman (output) from mailman id 1063729.1429473; Wed, 30 Jul 2025 10:39: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 1uh4DB-0000AY-M9; Wed, 30 Jul 2025 10:39:05 +0000 Received: by outflank-mailman (input) for mailman id 1063729; Wed, 30 Jul 2025 10:39:03 +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 1uh4D9-0007vC-QE for xen-devel@lists.xenproject.org; Wed, 30 Jul 2025 10:39:03 +0000 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [2a00:1450:4864:20::62a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 687a66f9-6d31-11f0-a320-13f23c93f187; Wed, 30 Jul 2025 12:39:02 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-af240271376so73441066b.2 for ; Wed, 30 Jul 2025 03:39: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 a640c23a62f3a-af8f1b17364sm183230166b.66.2025.07.30.03.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 03:39: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: 687a66f9-6d31-11f0-a320-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753871942; x=1754476742; 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=wsgRhZe0m3cfqTt4t1L2u+vUAFJZc+UMkUbqgwGoE0Q=; b=k5YYT1A3GFx6Vd44cS7Jkh9TzpNORafeiLtO4kHrpsgK4XjOjlXdPZimFTLWd8mXtS 83gNUfNbYmDX50RHbVRiiHaNu9YH0ZI5TmAUenuf2PjCDBteLo95xmGJYdbkbMvbADBn SrhB1v0ouZBxFlQ7ZOOpnZkividgKTFkHihBO8wHXIXef2rdc2iDgZH8tEZYk/+iaq0k AvfRN8ODEf9ahmBopXABXuThvvKHjDwl/rHiFiKIwzGKdyNxOYSOx6KCiTNeR709Vl/S uAULlMWBVvTsLDfS3ukCbMljFw2E0gO0FllO36prlhOfF0HrLrcKvhH5ePdk0hFXRrxg Xxjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753871942; x=1754476742; 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=wsgRhZe0m3cfqTt4t1L2u+vUAFJZc+UMkUbqgwGoE0Q=; b=fVGNpZiC57jGH7ZSDVUW/guW91dOgVhbzYoTHruBPZiAYML5TvUaSaGGnxCVrtpYIh EhxPDPeHxSQEgUboWGWcP6zZktB2LaHUwhohSgo0Na+8emHDrwMonm7WkxR/vAB2oroA nQyrUtt1WvY6jXD2zLlw+qxqSc1MbLKwCHd+9o2xmirLWKReFGk2q6yBncUbhSFw1urO uv74nljkNlO7nGx2OmhQ69NrQDNTKt4Q3/4SUQqQVuEkinpXZziLVuHSrrrqloJZlmV2 k8CPV+Xt51xLegTVJpaqgCvSGA8qkS2cqCDI5kfNbbdqjGtTf6lf604Y5mzlJ1P+AoY4 J8bQ== X-Gm-Message-State: AOJu0YxJw0uYay6CZBxu2KDhF2hi0ZnprMam56W80qfRnooiehgwwd/J 7g4SPUPkFkggCyJokFbznj/d0s1FIUznLGprvfo39Ql9BJOfq72FchFFtju5NDc9na4= X-Gm-Gg: ASbGncsYgfeGmIy9r2A101ipBiqUgt2bLuJOZ7FAy8ao6DHIxUyJMjyFLSTK6vCK5Hw YqB4crquaH9hygMlpSICf4QUoFZOWNyljEEr89UN4qf1vIMhJWOhuXa01wrK9sJeW7kj4Ms9RYm oDYY/PpsOb3oh8OKH3AzlthG0c5gKc0rKUIN1+HuLMXZm96So68sWeo1li5vaMxAcm1GV6mIVjQ Z7+bUlt4eCg6b7MEoW8md6hyBW4b5IvdLAxlBlj/Eu4xyHaxgJ39pdM5KWozvgdWFxm+zapdhVb bEBfEGWiTEZ8W2QjTTF1xq4lVcDTTUas3a8WQrCbFTbzAW33I+nTIgVz7dgNbWRxHXZ63cofh6E 3LXLxq2sZQ3LsYunG4OFzDJ0Kn3qzuE3MTPhzstPTU/YriOgujX4xI+BtoczpDeg3hwmp+XV38S nGXiqHcN+0S9YTO+atrvLSBA== X-Google-Smtp-Source: AGHT+IGM0vAoMOhI6Af0zqc0of5fi1WstWt38Ih/n/oVeZHcMS+r9FroanUBhVUNHhjsttIzhBaqXg== X-Received: by 2002:a17:907:d7c9:b0:ae0:ba0e:ae59 with SMTP id a640c23a62f3a-af8fd7642c0mr159234766b.7.1753871941369; Wed, 30 Jul 2025 03:39: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?= , 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 v11 3/6] xen: Make the maximum number of altp2m views configurable for x86 Date: Wed, 30 Jul 2025 10:38:47 +0000 Message-Id: <2cf413a9faaa9cd80e9a61b7bfb9ec0257e3c4c7.1753871755.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: 1753871959841116600 From: Petr Bene=C5=A1 This commit introduces the ability to configure the maximum number of altp2m views for the domain during its creation. Previously, the limits were hardc= oded to a maximum of 10. This change allows for greater flexibility in environme= nts that require more or fewer altp2m views. The maximum configurable limit for nr_altp2m on x86 is now set to MAX_NR_ALTP2M (which currently holds the MAX_EPTP value - 512). This cap is linked to the architectural limit of the EPTP-switching VMFUNC, which suppo= rts up to 512 entries. Despite there being no inherent need for limiting nr_alt= p2m in scenarios not utilizing VMFUNC, decoupling these components would necess= itate substantial code changes. xen_domctl_createdomain::altp2m is extended for a new field `nr`, that will configure this limit for a domain. Additionally, previous altp2m.opts value has been reduced from uint32_t to uint16_t so that both of these fields occ= upy as little space as possible. Accesses to the altp2m_p2m array are modified to respect the new nr_altp2m value. Accesses to the altp2m_(visible_)eptp arrays are unmodified, since these arrays always have fixed size of MAX_EPTP. Additional sanitization is introduced in the x86/arch_sanitise_domain_config to fix the altp2m.nr value to 10 if it is previously set to 0. This behavior is only temporary and immediately removed in the upcoming commit (which will disallow creating a domain with enabled altp2m with zero nr_altp2m). The reason for this temporary workaround is to retain the legacy behavior until the feature is fully activated in libxl. Also, arm/arch_sanitise_domain_config is extended to not allow requesting non-zero altp2ms. Signed-off-by: Petr Bene=C5=A1 Acked-by: Jan Beulich --- xen/arch/arm/domain.c | 2 +- xen/arch/x86/domain.c | 40 ++++++++++++++--- xen/arch/x86/hvm/hvm.c | 8 +++- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/include/asm/altp2m.h | 28 ++++++++++-- xen/arch/x86/include/asm/domain.h | 9 ++-- xen/arch/x86/include/asm/p2m.h | 4 +- xen/arch/x86/mm/altp2m.c | 72 ++++++++++++++++--------------- xen/arch/x86/mm/hap/hap.c | 6 +-- xen/arch/x86/mm/mem_access.c | 20 +++------ xen/arch/x86/mm/mem_sharing.c | 4 +- xen/arch/x86/mm/p2m-ept.c | 7 +-- xen/arch/x86/mm/p2m-pt.c | 2 + xen/arch/x86/mm/p2m.c | 8 ++-- xen/common/domain.c | 6 +++ xen/include/public/domctl.h | 5 ++- xen/include/xen/sched.h | 4 ++ 17 files changed, 149 insertions(+), 78 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 310c578909..863ae18157 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 1881c8ac52..b4ccb7e7fb 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4675,6 +4675,12 @@ static int do_altp2m_op( goto out; } =20 + if ( d->nr_altp2m =3D=3D 0 ) + { + rc =3D -EOPNOTSUPP; + goto out; + } + if ( (rc =3D xsm_hvm_altp2mhvm_op(XSM_OTHER, d, mode, a.cmd)) ) goto out; =20 @@ -5275,7 +5281,7 @@ void hvm_fast_singlestep(struct vcpu *v, uint16_t p2m= idx) if ( !hvm_is_singlestep_supported() ) return; =20 - if ( p2midx >=3D MAX_ALTP2M ) + if ( p2midx >=3D v->domain->nr_altp2m ) return; =20 v->arch.hvm.single_step =3D true; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 64f0dbbd4a..f7a2eecca4 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -4974,7 +4974,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_u= ser_regs *regs) { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; ++i ) + for ( i =3D 0; i < currd->nr_altp2m; ++i ) { if ( currd->arch.altp2m_eptp[i] =3D=3D mfn_x(INVALID_MFN) ) continue; diff --git a/xen/arch/x86/include/asm/altp2m.h b/xen/arch/x86/include/asm/a= ltp2m.h index c57a8c5588..8ecd74f363 100644 --- a/xen/arch/x86/include/asm/altp2m.h +++ b/xen/arch/x86/include/asm/altp2m.h @@ -13,12 +13,32 @@ #include /* for struct vcpu, struct domain */ #include /* for vcpu_altp2m */ =20 +static inline bool altp2m_is_eptp_valid(const struct domain *d, + unsigned int idx) +{ + /* There must be enough EPTP entries to cover all altp2m indices */ + BUILD_BUG_ON(MAX_EPTP < MAX_NR_ALTP2M); + + /* Domain should not have more altp2m entries than MAX_NR_ALTP2M */ + ASSERT(d->nr_altp2m <=3D MAX_NR_ALTP2M); + + /* EPTP index is used as altp2m index */ + return idx < d->nr_altp2m && + d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] !=3D + mfn_x(INVALID_MFN); +} + /* Alternate p2m HVM on/off per domain */ static inline bool altp2m_active(const struct domain *d) { return d->arch.altp2m_active; } =20 +static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v) +{ + return vcpu_altp2m(v).p2midx; +} + /* Alternate p2m VCPU */ void altp2m_vcpu_initialise(struct vcpu *v); void altp2m_vcpu_destroy(struct vcpu *v); @@ -26,11 +46,13 @@ void altp2m_vcpu_destroy(struct vcpu *v); int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn); void altp2m_vcpu_disable_ve(struct vcpu *v); =20 -static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v) +#else + +static inline bool altp2m_is_eptp_valid(const struct domain *d, + unsigned int idx) { - return vcpu_altp2m(v).p2midx; + return false; } -#else =20 static inline bool altp2m_active(const struct domain *d) { diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index 8749c5eba0..02a00e1c07 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -258,11 +258,12 @@ struct paging_vcpu { struct shadow_vcpu shadow; }; =20 -#define MAX_NESTEDP2M 10 +#define MAX_EPTP (PAGE_SIZE / sizeof(uint64_t)) +#define MAX_NR_ALTP2M MAX_EPTP +#define MAX_NESTEDP2M 10 =20 -#define MAX_ALTP2M 10 /* arbitrary */ #define INVALID_ALTP2M 0xffff -#define MAX_EPTP (PAGE_SIZE / sizeof(uint64_t)) + struct p2m_domain; struct time_scale { int shift; @@ -354,7 +355,7 @@ struct arch_domain #ifdef CONFIG_ALTP2M /* altp2m: allow multiple copies of host p2m */ bool altp2m_active; - struct p2m_domain *altp2m_p2m[MAX_ALTP2M]; + struct p2m_domain **altp2m_p2m; mm_lock_t altp2m_list_lock; uint64_t *altp2m_eptp; uint64_t *altp2m_visible_eptp; diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 6ead4891a4..f7e557db01 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -903,7 +903,7 @@ static inline struct p2m_domain *p2m_get_altp2m(struct = vcpu *v) if ( index =3D=3D INVALID_ALTP2M ) return NULL; =20 - BUG_ON(index >=3D MAX_ALTP2M); + BUG_ON(index >=3D v->domain->nr_altp2m); =20 return v->domain->arch.altp2m_p2m[index]; } @@ -913,7 +913,7 @@ static inline bool p2m_set_altp2m(struct vcpu *v, unsig= ned int idx) { struct p2m_domain *orig; =20 - BUG_ON(idx >=3D MAX_ALTP2M); + BUG_ON(idx >=3D v->domain->nr_altp2m); =20 if ( idx =3D=3D vcpu_altp2m(v).p2midx ) return false; diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c index 6fe1e9ed6b..0261360aae 100644 --- a/xen/arch/x86/mm/altp2m.c +++ b/xen/arch/x86/mm/altp2m.c @@ -9,12 +9,16 @@ #include #include #include +#include #include "mm-locks.h" #include "p2m.h" =20 void altp2m_vcpu_initialise(struct vcpu *v) { + if ( !v->domain->nr_altp2m ) + return; + if ( v !=3D current ) vcpu_pause(v); =20 @@ -32,6 +36,9 @@ altp2m_vcpu_destroy(struct vcpu *v) { struct p2m_domain *p2m; =20 + if ( !v->domain->nr_altp2m ) + return; + if ( v !=3D current ) vcpu_pause(v); =20 @@ -122,7 +129,12 @@ int p2m_init_altp2m(struct domain *d) struct p2m_domain *hostp2m =3D p2m_get_hostp2m(d); =20 mm_lock_init(&d->arch.altp2m_list_lock); - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + d->arch.altp2m_p2m =3D xvzalloc_array(struct p2m_domain *, d->nr_altp2= m); + + if ( !d->arch.altp2m_p2m ) + return -ENOMEM; + + for ( i =3D 0; i < d->nr_altp2m; i++ ) { d->arch.altp2m_p2m[i] =3D p2m =3D p2m_init_one(d); if ( p2m =3D=3D NULL ) @@ -143,7 +155,7 @@ void p2m_teardown_altp2m(struct domain *d) unsigned int i; struct p2m_domain *p2m; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( !d->arch.altp2m_p2m[i] ) continue; @@ -151,6 +163,8 @@ void p2m_teardown_altp2m(struct domain *d) d->arch.altp2m_p2m[i] =3D NULL; p2m_free_one(p2m); } + + XVFREE(d->arch.altp2m_p2m); } =20 int altp2m_get_effective_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *= mfn, @@ -200,7 +214,7 @@ bool p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsig= ned int idx) struct domain *d =3D v->domain; bool rc =3D false; =20 - if ( idx >=3D MAX_ALTP2M ) + if ( idx >=3D d->nr_altp2m ) return rc; =20 altp2m_list_lock(d); @@ -306,8 +320,8 @@ static void p2m_reset_altp2m(struct domain *d, unsigned= int idx, { struct p2m_domain *p2m; =20 - ASSERT(idx < MAX_ALTP2M); - p2m =3D array_access_nospec(d->arch.altp2m_p2m, idx); + ASSERT(idx < d->nr_altp2m); + p2m =3D d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; =20 p2m_lock(p2m); =20 @@ -332,7 +346,7 @@ void p2m_flush_altp2m(struct domain *d) =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { p2m_reset_altp2m(d, i, ALTP2M_DEACTIVATE); d->arch.altp2m_eptp[i] =3D mfn_x(INVALID_MFN); @@ -348,9 +362,9 @@ static int p2m_activate_altp2m(struct domain *d, unsign= ed int idx, struct p2m_domain *hostp2m, *p2m; int rc; =20 - ASSERT(idx < MAX_ALTP2M); + ASSERT(idx < d->nr_altp2m); =20 - p2m =3D array_access_nospec(d->arch.altp2m_p2m, idx); + p2m =3D d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; hostp2m =3D p2m_get_hostp2m(d); =20 p2m_lock(p2m); @@ -388,7 +402,7 @@ int p2m_init_altp2m_by_id(struct domain *d, unsigned in= t idx) int rc =3D -EINVAL; struct p2m_domain *hostp2m =3D p2m_get_hostp2m(d); =20 - if ( idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) + if ( idx >=3D d->nr_altp2m ) return rc; =20 altp2m_list_lock(d); @@ -415,7 +429,7 @@ int p2m_init_next_altp2m(struct domain *d, uint16_t *id= x, =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) continue; @@ -437,7 +451,7 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned= int idx) struct p2m_domain *p2m; int rc =3D -EBUSY; =20 - if ( !idx || idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) + if ( !idx || idx >=3D d->nr_altp2m ) return rc; =20 rc =3D domain_pause_except_self(d); @@ -450,7 +464,7 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned= int idx) if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] !=3D mfn_x(INVALID_MFN) ) { - p2m =3D array_access_nospec(d->arch.altp2m_p2m, idx); + p2m =3D d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; =20 if ( !_atomic_read(p2m->active_vcpus) ) { @@ -475,7 +489,7 @@ int p2m_switch_domain_altp2m_by_id(struct domain *d, un= signed int idx) struct vcpu *v; int rc =3D -EINVAL; =20 - if ( idx >=3D MAX_ALTP2M ) + if ( idx >=3D d->nr_altp2m ) return rc; =20 rc =3D domain_pause_except_self(d); @@ -510,13 +524,11 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned = int idx, mfn_t mfn; int rc =3D -EINVAL; =20 - if ( idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, idx) ) return rc; =20 hp2m =3D p2m_get_hostp2m(d); - ap2m =3D array_access_nospec(d->arch.altp2m_p2m, idx); + ap2m =3D d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; =20 p2m_lock(hp2m); p2m_lock(ap2m); @@ -572,7 +584,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t= gfn, =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { p2m_type_t t; p2m_access_t a; @@ -595,7 +607,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t= gfn, else { /* At least 2 altp2m's impacted, so reset everything */ - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( i =3D=3D last_reset_idx || d->arch.altp2m_eptp[i] =3D=3D mfn_x(INVALID_MFN) ) @@ -659,12 +671,11 @@ int p2m_set_suppress_ve_multi(struct domain *d, =20 if ( sve->view > 0 ) { - if ( sve->view >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) = || - d->arch.altp2m_eptp[array_index_nospec(sve->view, MAX_EPTP)] = =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, sve->view) ) return -EINVAL; =20 - p2m =3D ap2m =3D array_access_nospec(d->arch.altp2m_p2m, sve->view= ); + p2m =3D ap2m =3D + d->arch.altp2m_p2m[array_index_nospec(sve->view, d->nr_altp2m)= ]; } =20 p2m_lock(host_p2m); @@ -727,12 +738,11 @@ int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, = bool *suppress_ve, =20 if ( altp2m_idx > 0 ) { - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP)= || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]= =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) return -EINVAL; =20 - p2m =3D ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_id= x); + p2m =3D ap2m =3D + d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m= )]; } else p2m =3D host_p2m; @@ -761,13 +771,7 @@ int p2m_set_altp2m_view_visibility(struct domain *d, u= nsigned int altp2m_idx, =20 altp2m_list_lock(d); =20 - /* - * Eptp index is correlated with altp2m index and should not exceed - * min(MAX_ALTP2M, MAX_EPTP). - */ - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] =3D= =3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) rc =3D -EINVAL; else if ( visible ) d->arch.altp2m_visible_eptp[array_index_nospec(altp2m_idx, MAX_EPT= P)] =3D diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index 384c24028f..4aec98109d 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -516,7 +516,7 @@ int hap_enable(struct domain *d, u32 mode) d->arch.altp2m_visible_eptp[i] =3D mfn_x(INVALID_MFN); } =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { rv =3D p2m_alloc_table(d->arch.altp2m_p2m[i]); if ( rv !=3D 0 ) @@ -541,7 +541,7 @@ void hap_final_teardown(struct domain *d) =20 #ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() ) - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) p2m_teardown(d->arch.altp2m_p2m[i], true, NULL); #endif =20 @@ -595,7 +595,7 @@ void hap_teardown(struct domain *d, bool *preempted) FREE_XENHEAP_PAGE(d->arch.altp2m_eptp); FREE_XENHEAP_PAGE(d->arch.altp2m_visible_eptp); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { p2m_teardown(d->arch.altp2m_p2m[i], false, preempted); if ( preempted && *preempted ) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 0779c41161..e6b609064c 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -351,12 +351,10 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, = uint32_t nr, /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP)= || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]= =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) return -EINVAL; =20 - ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + ap2m =3D d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_a= ltp2m)]; } #endif =20 @@ -409,12 +407,10 @@ long p2m_set_mem_access_multi(struct domain *d, /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP)= || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]= =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) return -EINVAL; =20 - ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + ap2m =3D d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_a= ltp2m)]; } #endif =20 @@ -474,12 +470,10 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, x= enmem_access_t *access, } else if ( altp2m_idx ) /* altp2m view 0 is treated as the hostp2m */ { - if ( altp2m_idx >=3D min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP)= || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]= =3D=3D - mfn_x(INVALID_MFN) ) + if ( !altp2m_is_eptp_valid(d, altp2m_idx) ) return -EINVAL; =20 - p2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + p2m =3D d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_al= tp2m)]; } #endif =20 @@ -496,7 +490,7 @@ void arch_p2m_set_access_required(struct domain *d, boo= l access_required) if ( altp2m_active(d) ) { unsigned int i; - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { struct p2m_domain *p2m =3D d->arch.altp2m_p2m[i]; =20 diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index da28266ef0..4787b27964 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -901,6 +901,7 @@ static int nominate_page(struct domain *d, gfn_t gfn, if ( !page || is_special_page(page) ) goto out; =20 +#ifdef CONFIG_ALTP2M /* Check if there are mem_access/remapped altp2m entries for this page= */ if ( altp2m_active(d) ) { @@ -912,7 +913,7 @@ static int nominate_page(struct domain *d, gfn_t gfn, =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { ap2m =3D d->arch.altp2m_p2m[i]; if ( !ap2m ) @@ -929,6 +930,7 @@ static int nominate_page(struct domain *d, gfn_t gfn, =20 altp2m_list_unlock(d); } +#endif /* CONFIG_ALTP2M */ =20 /* Try to convert the mfn to the sharable type */ ret =3D page_make_sharable(d, page, expected_refcnt, validate_only); diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index ae262bfcc2..b854a08b4c 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1302,7 +1302,7 @@ static void ept_set_ad_sync(struct domain *d, bool va= lue) { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { struct p2m_domain *p2m; =20 @@ -1576,7 +1576,8 @@ void __init setup_ept_dump(void) #ifdef CONFIG_ALTP2M void p2m_init_altp2m_ept(struct domain *d, unsigned int i) { - struct p2m_domain *p2m =3D array_access_nospec(d->arch.altp2m_p2m, i); + struct p2m_domain *p2m =3D + d->arch.altp2m_p2m[array_index_nospec(i, d->nr_altp2m)]; struct p2m_domain *hostp2m =3D p2m_get_hostp2m(d); struct ept_data *ept; =20 @@ -1595,7 +1596,7 @@ unsigned int p2m_find_altp2m_by_eptp(struct domain *d= , uint64_t eptp) =20 altp2m_list_lock(d); =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] =3D=3D mfn_x(INVALID_MFN) ) continue; diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 666abd46be..5a6ce2f8bc 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -519,12 +519,14 @@ int p2m_pt_handle_deferred_changes(uint64_t gpa) struct p2m_domain *p2m =3D p2m_get_hostp2m(current->domain); int rc; =20 +#ifdef CONFIG_ALTP2M /* * Should altp2m ever be enabled for NPT / shadow use, this code * should be updated to make use of the active altp2m, like * ept_handle_misconfig(). */ ASSERT(!altp2m_active(current->domain)); +#endif =20 p2m_lock(p2m); rc =3D do_recalc(p2m, PFN_DOWN(gpa)); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 5a3fda903e..e802f2e4e6 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -106,7 +106,7 @@ void p2m_change_entry_type_global(struct domain *d, { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) { @@ -152,7 +152,7 @@ bool p2m_memory_type_changed(struct domain *d) { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) { @@ -939,7 +939,7 @@ void p2m_change_type_range(struct domain *d, { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) { @@ -1015,7 +1015,7 @@ int p2m_finish_type_change(struct domain *d, { unsigned int i; =20 - for ( i =3D 0; i < MAX_ALTP2M; i++ ) + for ( i =3D 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] !=3D mfn_x(INVALID_MFN) ) { diff --git a/xen/common/domain.c b/xen/common/domain.c index 5241a1629e..104e917f07 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -822,6 +822,12 @@ struct domain *domain_create(domid_t domid, if ( config ) { d->options =3D config->flags; +#ifdef CONFIG_ALTP2M + d->nr_altp2m =3D config->altp2m.nr; +#else + ASSERT(!config->altp2m.nr); +#endif + d->vmtrace_size =3D config->vmtrace_size; } =20 diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 0c75d9d27f..8f6708c0a7 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 df23411869..a59965b606 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 18:55:07 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=1753871970; cv=none; d=zohomail.com; s=zohoarc; b=VreRnCvnjykirdkZ4lvxNxPMJ8SPoFR8Uss04msBlPQIJaMuzLFAKTdXH8MPad4JYL1cUGAIcakQsA7kQKtJRTzUSLlQ1SNTa1c7sxDGju753mUr+iURJ7Ryj2c4k2ac5zapyRhX1hWFSYRBTGKeDallKK+Lt6NXrZK9atwMJw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753871970; 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=KPrV+rmqSI9Pn16lUWVeeXFpruWORSVEh0IsEq9O8/U=; b=QjRrjqyZ78UitsSiUtWCu6fvhrAHM0G2W3gVXXQzUs2LwONLTwCOse1PEzGAP7FklVmZcqlO/JCD7+xElr3QvPLWxCUuRKyFRBNWpUpsgbGz1ri9J+LWvPrjy6r6lcafkI91vwrQg8R9qlhHEzlsw+ACcOZiRpQTEp6GPb18tn4= 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 1753871970851299.97426576214855; Wed, 30 Jul 2025 03:39:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063730.1429480 (Exim 4.92) (envelope-from ) id 1uh4DC-0000E6-5e; Wed, 30 Jul 2025 10:39:06 +0000 Received: by outflank-mailman (output) from mailman id 1063730.1429480; Wed, 30 Jul 2025 10:39:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uh4DB-0000DH-Uq; Wed, 30 Jul 2025 10:39:05 +0000 Received: by outflank-mailman (input) for mailman id 1063730; Wed, 30 Jul 2025 10:39: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 1uh4DA-0007vS-KE for xen-devel@lists.xenproject.org; Wed, 30 Jul 2025 10:39:04 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 68f5717e-6d31-11f0-b895-0df219b8e170; Wed, 30 Jul 2025 12:39:03 +0200 (CEST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-615547ee514so537544a12.1 for ; Wed, 30 Jul 2025 03:39:03 -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 a640c23a62f3a-af8f1b17364sm183230166b.66.2025.07.30.03.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 03:39: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: 68f5717e-6d31-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753871942; x=1754476742; 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=KPrV+rmqSI9Pn16lUWVeeXFpruWORSVEh0IsEq9O8/U=; b=NFJZc5avR51LjVp91DcHPesOUYVrH+v90F5ILuxoNVfZG5NTuPbyfFbSeKUL1VB+0V 2ABMd0li4vZ4CDYWakiwuqzjJSMXxlwBlw1tp7apxevzsuqvjj6iWzU4aMrBDLU5wwq5 BP4rtea94Lf+inw4ihktynnOTD8uFTuC94PMsboH4l7oOuYySga5MgSWARKoOjOan5NH yq3bIzmx0QFSxYIFoVLqrJ3owmoECPl5tlB/sxsZ44j6PopjDGz8ZyDbkAK6YhGR5X0C lI0Qx2DbmQLfnqwsWj0/Ahz1ypYlBLpMo05l0FdouMXqWJpXjUUaMaOzwN6d9oPx3Dqp NSfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753871942; x=1754476742; 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=KPrV+rmqSI9Pn16lUWVeeXFpruWORSVEh0IsEq9O8/U=; b=Y+6hTc4HuKholIWjSqxqKNxNGbJuq66im8yJrMyHc7nZtXSDpFuD7p0oaDAFMDcqdw KYKZCa0LTRA03T8sYyq6HzCQa+epfl62iNA5j8r7tLHkHOue5FypG6PVDPWc3qD38lw+ kzMjL3ltdxagBMhKcraVvcWTIXyGsv73wET6eX5kKuXQzoPE62QdwY8Z/unFK0ELzbdP hEMl61N1364OpyvNT5yAPEm1iwjiRjYlqWaVfPpM8QK/XgQU4YCu4O2Xft5zMyZAkxQC 1P1DQbHUP1z9bOFxbxRT8A6BS/C0eLd+kob+VCh6IXn89tPpkJP9UDfj46kviw4hMJS+ IVhw== X-Gm-Message-State: AOJu0YzZg4XzFwGZGSu3VNHEdY6cVh8uHmJvUS180xSStQtsNDLz3IFL wZS8RDCkMUPS0CU9E9GqcLal0bHMdTC8MBu5qUWlcWua1tLSu0eSJ58xYQRF/HxMnJc= X-Gm-Gg: ASbGncscSMmCG4PNFqPoylggc+0ZnS8rQfBcBkJd50uxwXTOiU1AjQ0d0AC7MRMfqzd c5J7kYl6YtJPw7gvzQwZSdhPyTpA2O1tHZvdUwvPhl6l5OVKLWADt4yPTJXP9ZmKfZJCVpIcEpr l4XtTxW1fPIeKQVT4wVIvFSHZMROoCEq6Lj/au8w091s0H4XWWvOI916Md6wRZ8fC6X/yfCMWW+ A62T+b+NSdfPsaqJSdSV/Iprz943bppimGvhwnv1GK1NJtH0WOpyUIbw/i7HnXhhidXUQJDG16K VsZhx9S/6cfxz1fb1KueYYucBks5RijmnsxV/iBrKKJeFy6kYQ0KZKyjeLeK7Os89ZnSSI3QHNp ZiFhJ+QuTOxlCeCNlM4cgjiNMai8oW61fDUzv0KUPcS17HZvq6s0Ue32BXowzp2f8k5iHY0OXlB Rx8UTCN02ZjuQHwcKkMWvTK+MwNItFgNFjVJFEOze652U= X-Google-Smtp-Source: AGHT+IFRbAN9NZXJMqdHNF5l+YypqX3z8cWQY3Mr4tkrtcRK9CmUzw9fD04N7NXaiUMXPgoRV7OnXw== X-Received: by 2002:a17:907:96a3:b0:ae3:5118:96b3 with SMTP id a640c23a62f3a-af8fd6a393bmr107372166b.3.1753871942158; Wed, 30 Jul 2025 03:39:02 -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 v11 4/6] tools/libxl: Activate the altp2m_count feature Date: Wed, 30 Jul 2025 10:38:48 +0000 Message-Id: <02436b30cfa649ec843cee384ea26c58f1b8caf5.1753871755.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: 1753871971635116600 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 4042ae1a89..36772637e0 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 18:55:07 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=1753871963; cv=none; d=zohomail.com; s=zohoarc; b=FgjgVzDx3jtpFYEEgesuGapsm733Y6CHmTYgTJpcCuocyfXFMN4F13mWUuPxLZx7F0mib9mOmIijtTybjwjQJNvG5V2dlZ9y/pIfdIJw/+UeePG+P4Yc75Bc0oZvuNt6ctk4HWb7q2FEwLI+qUnR8wzeo4T95rPlxfid5x2i/mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753871963; 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=i3x13OOq8qrhOEJmmFL6s6o6kkOlc39a5oRjDXx9RKbUBtVfHoPqb/Ap5O3GZFqVWKq+9FvXhm9zeF/41gQ49kfnUufNV8VKeDKXVO20syBdQF9KZufI3lTfjTJHcTVELACTwioFdgpK7DIkIfk4QQkVuBrUkjvNk/ITSCnafr4= 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 1753871963627669.470241581876; Wed, 30 Jul 2025 03:39:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063731.1429485 (Exim 4.92) (envelope-from ) id 1uh4DC-0000OG-OI; Wed, 30 Jul 2025 10:39:06 +0000 Received: by outflank-mailman (output) from mailman id 1063731.1429485; Wed, 30 Jul 2025 10:39:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uh4DC-0000NU-Fk; Wed, 30 Jul 2025 10:39:06 +0000 Received: by outflank-mailman (input) for mailman id 1063731; Wed, 30 Jul 2025 10:39:04 +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 1uh4DA-0007vC-QR for xen-devel@lists.xenproject.org; Wed, 30 Jul 2025 10:39:04 +0000 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [2a00:1450:4864:20::529]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 696b43f0-6d31-11f0-a320-13f23c93f187; Wed, 30 Jul 2025 12:39:03 +0200 (CEST) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-61539f6815fso569744a12.2 for ; Wed, 30 Jul 2025 03:39:04 -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 a640c23a62f3a-af8f1b17364sm183230166b.66.2025.07.30.03.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 03:39:02 -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: 696b43f0-6d31-11f0-a320-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753871943; x=1754476743; 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=myCOjy5AlwEAEeYWdeB1cmjCbhIGNW2RDrEZChzShWg40GnoBZXiiAASyfqpBSCYwO FPoU6ywQCZPqTLqcYaDx3QDyrLVOxtpN3S3DG8kGf4Q6L/GXiHC13R0Eq3Kvx+hDgHkk 8OpMqK4yieGss8G5oAq9Go/hoqrWZs32jjGGkSCiQjQTD5MDwZ9JAjhk6GLg22EgnAKB EzxRqi8zdqK4+xZ5TopQFLFoX2MLCv34qPl7aVyje35BTwq2Wzlk4eVTgATJUW+m+w1/ o0rkpj1p9PYgsCbKMFiTm/LRlYtK1eiEL55YHj1tqfcaGQ4OqaxeBmKyJcCvFReLSuSj sdlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753871943; x=1754476743; 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=WjI14gu09l8edgkxcwmeSi9SZLtORjDbd3EEdTok/as9AXViz929V9HKSrO33U0xV0 52VHYP9cs6ewA0yP5Z1uNCYl3P54AKtvbIAUNzCfx4b7+FE5fsWjIOasQVYrjpIw5NzL t+tmKE14hPqS1eF80Gzanawkj9mAWc5g57FGf+NaNWkD1pLOENTAom+27wjSVJ2/RTNo GFdYYuuM6ztFBEDNK8G7ZKGS4xQt35l9tCxaJruP6wzc2AXtUOiaKHnRTJFbMtJb11RV 2t91e0pJEaKmI8CAnoBCNwV5TbHkegicWA3kgn4kiDVvd/rObmZBQYIumWL6Q/Vhv5Yv zpNQ== X-Gm-Message-State: AOJu0YzzHHVBUi81QixqudBPZeHWB6fAZfh/dVtC1hzIJThBOmQJqKxE 8B8jP/45WIHrxWQwGF/oBJBvbfIon4gr0Z+Jir3QgQQEVZNWntIBDo2VD1H2TcKvQfQ= X-Gm-Gg: ASbGnctL0m+VZsh3agm7ixJkSSkgUx/ltYoWNzmDOHXQptzSjtHJFCbVMOvR5YF7FWW X7ec7O4qxoVNN4+DGT2OsJK45/AJw7RFqoIzKsfhzLIt79N18OzauK4fv7nJr9lVVKrwjG8oh/2 P5cPgAMyvodCobZRhrHEJHEMuwTJewgKE7+XyR09Gj+waYnrbPbDOHHjYiKWQyHaKDHAoc2UqPe q6yYDmapLLlvkSD1PMn0MWu8yEK8jN8j3Ynf0rvB1f0uU51P5N3eTTg25cry7jNnFdy6i1IPcyM 3r9ZaW+2h0zzGKJkfWkJ0i550KUEnWs8RA9aeUKpk7ibmJxww1ZemYEc9i3ZibWvdHr8klYzz5S xxrFgK/oIJdQeF/Wh+fLY6IQdLzMUzXPxfdo8FZcAb3NAwpCVVIf0bPE1aIOH9lpvo3EAZRJZnz w2gUn8A+sbOfMRhwkqElD9nmivslCvG2x8 X-Google-Smtp-Source: AGHT+IGFiXekcR8blKO5TUEoiFDOiAdM5EjlIbRUyZkhFA/cY+/QuElLp1rzA57PY3FCyVK6uOsLZg== X-Received: by 2002:a17:907:96a3:b0:ae3:5118:96b3 with SMTP id a640c23a62f3a-af8fd6a393bmr107374166b.3.1753871943107; Wed, 30 Jul 2025 03:39:03 -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 v11 5/6] xen/x86: Disallow creating domains with altp2m enabled and altp2m.nr == 0 Date: Wed, 30 Jul 2025 10:38:49 +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: 1753871965790116600 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 18:55:07 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=1753871973; cv=none; d=zohomail.com; s=zohoarc; b=DRvF3hzt8fG3Z+/Dal15F5dSsxCMu2dAwrzHdLw04SY/ucNxCKrdGe5tXP+8XXaT7wPce9sdgU2L2ESkL4lfHS02hvax1j9HE/mDoFauOhgGHf7rbBAeYmCcCRtG3pAIATlEW5RMkIlw1aSfS6jPlX82cHZDIb2x44XeLzRNCzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753871973; 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=Mj/QERJtgo4duoWL6XiMLOH0grctMj/7lgH4Zp+5JzN5ppbuFASH+N/aOPwccMaiMbINhYTpwtANiblfZSQlk8J5wtQLj1zPOKsBropMq8r1wJ4SOhPB17ZPu9x/SNPoGAvmIHkXDL0eCM5Yp4PyIyq7wfBR3zfJcRmHU8v0rI8= 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 1753871973084605.2643992921402; Wed, 30 Jul 2025 03:39:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063732.1429503 (Exim 4.92) (envelope-from ) id 1uh4DE-0000wx-Vd; Wed, 30 Jul 2025 10:39:08 +0000 Received: by outflank-mailman (output) from mailman id 1063732.1429503; Wed, 30 Jul 2025 10:39: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 1uh4DE-0000wg-S2; Wed, 30 Jul 2025 10:39:08 +0000 Received: by outflank-mailman (input) for mailman id 1063732; Wed, 30 Jul 2025 10:39:07 +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 1uh4DD-0007vS-39 for xen-devel@lists.xenproject.org; Wed, 30 Jul 2025 10:39:07 +0000 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [2a00:1450:4864:20::531]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6a0ab624-6d31-11f0-b895-0df219b8e170; Wed, 30 Jul 2025 12:39:05 +0200 (CEST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-615877015daso146585a12.2 for ; Wed, 30 Jul 2025 03:39: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 a640c23a62f3a-af8f1b17364sm183230166b.66.2025.07.30.03.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 03:39: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: 6a0ab624-6d31-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753871944; x=1754476744; 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=dznoFTT96gFE6oEuro4w9mWy5e/y3Tc/FFfpP3nC3KKtID+igrbPcotij/Ws8P5BwG gTuUJQEpsrVCL3wt1CDVEs/LKWxDxAYu+/4JaQtMVyyKY3qYM7aQn4WyuTFlfxqNF488 wQEUm81IjBmE4Fge4ntU02Q+1pzrXe/oUum6QS40+j4UlpN+i6I0drpQ0YAq/WPPQoD2 ZZFMPWpakIuRQR2/F+9fBUM2jJxUew8/oDgYzU18y2uOj8Gl60+yjpaT4xSzfT7rY1r9 pcA06PPLPLPKo1Pm9N4CrfZTJMFKPPXOklSAhiAV/T2OGiDlq3WJ6FfBk7oV5FXvojAR nybQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753871944; x=1754476744; 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=iw94h7WbXuTpdMb+E9FAAQKD/3t9aufeD/52W3H99oIq0MpohSkOGqN/epJbBNj8Lo rFgBW/Wmopbqffw8A/ywizNbAgfCdWq2SmU973li6NymPVETuS3Z+umrwqOTkNoN3JbR 2r8pFHswmqlvv617GMtNDmxlIMuqQ5sM/6EDjpYgCii3W1paKEnWEZxEJ9lErEXONXho /HKF/7mvO7sfUpuo19/+zhjWd0y7aydyGEyFfVNVpzqGGT78B0zNrBdCqyVCx1YVHms6 UzsXS72UR+jZ+qu4u1YITa9vl5p8RvLX+jss6MLhgMkIeg/iRl8i8LlKWQz550zMp9w9 VlfA== X-Gm-Message-State: AOJu0YxLMP2XsrAMyBsqtPSSG6A1nL4Cp+7okC0vxyVFvmdvU0Y9vKt3 irZFllMq585ze6lKCYJjBNQNIE1VTlM2z2BvawPILai7+zihCXu6FW6In9li0zBYkSw= X-Gm-Gg: ASbGncuvrR+UirOqvIYR8zNhIDljLU3taXQhT6HwdNODiH5mhei06QyTfg42OG9Jr0i VCN01plTBJFx9BmAiVOMFfJ6Gkqpw0DiAf3cyk4qc0OB6b5MNwJA5oP88Dqrtg2h6cvlZhF/y2r 8Lh9mhAQ9awuti35E6TMWvb1+jCIBSJeii0d8X6XgauLsSF2YbY58xHqcyS3G7r5t3pl9h9sw2D e17WNM7h3lqVjnTtQZcxYmwInjsqIo/1YDiLUDxC8hFTut2Bfpsxt/zQ1Bk+DWx10dSTkDc1Icz gF2B9g67qNCVlpNuQEzKoXNclkNy23XHaOnpNEj8ZubO3r4riTtjGQbUrhlpzla7GEHIqu+FWkh Crm+Pp1F/5OJUQ+tM5ENJQ0I3I4qd1g0IzjfQ0H1oBX4liRWPJZU2rCBIH6DFzStHDlKoa0vxkH ZHiCyifZQwyI4wF3/qHeH7ug== X-Google-Smtp-Source: AGHT+IGVcZV8dA9V5fnuk47cxhs62A8AFweUYqCbRblaIhawsrNcQuuuwv/fAna5qUgKC1GOynrtaA== X-Received: by 2002:a17:907:7ba2:b0:ae3:63fd:c3b4 with SMTP id a640c23a62f3a-af8fd73bb97mr123224966b.5.1753871944015; Wed, 30 Jul 2025 03:39: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?= , Christian Lindig , David Scott , Anthony PERARD , Christian Lindig Subject: [PATCH v11 6/6] tools/ocaml: Add altp2m_count parameter Date: Wed, 30 Jul 2025 10:38:50 +0000 Message-Id: <39d3e8bca948b485040a7189135c388a5b70f9fa.1753871755.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: 1753871973644116600 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