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=1753954105; cv=none; d=zohomail.com; s=zohoarc; b=jFQ71aDd/H+pjDlt2MgnH/IanRtcVAGUf4ZAKdMJ5oRS64RL3gUR/9JW5tm/fzlAijlA/YL6brekHcrynDHiBqj+SkGwAuuV80u2+0j+UgB8msneBuk/GZB0ybNqrErfyYB4VdCeQncFGyQHIbcNbiwNxwFTSiJM2molBuzqR6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753954105; 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=VdUDk8PNeElBQFIXVeH+4JTV5pz3z+NOKkKyz1LFf2U=; b=J5ltLzon1Skj6Lzet5mGgEbZWoq6/0Po3ZmjjuQnIQHayaCCTeetzqer9qKWH2YNsJ2s0m9t3knycg/8R3oMTcfsuZM5tEoFaXcG1z1hBnY0h898I4ljTV/anF9+zQXldBYqc2M3O3v+BOa4Kp+BLs/qyOC5oontZ+yQRHRxdVw= 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 1753954105502153.62462199534286; Thu, 31 Jul 2025 02:28:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1065150.1430496 (Exim 4.92) (envelope-from ) id 1uhPa8-0000M5-Sg; Thu, 31 Jul 2025 09:28:12 +0000 Received: by outflank-mailman (output) from mailman id 1065150.1430496; Thu, 31 Jul 2025 09:28:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uhPa8-0000LC-Lw; Thu, 31 Jul 2025 09:28:12 +0000 Received: by outflank-mailman (input) for mailman id 1065150; Thu, 31 Jul 2025 09:28:11 +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 1uhPa7-0000Jb-AZ for xen-devel@lists.xenproject.org; Thu, 31 Jul 2025 09:28:11 +0000 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [2a00:1450:4864:20::330]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ac1871b7-6df0-11f0-b895-0df219b8e170; Thu, 31 Jul 2025 11:28:09 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-456053b5b8cso958275e9.3 for ; Thu, 31 Jul 2025 02:28:09 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-458953cfcc1sm60905485e9.17.2025.07.31.02.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 02:28:08 -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: ac1871b7-6df0-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753954089; x=1754558889; 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=VdUDk8PNeElBQFIXVeH+4JTV5pz3z+NOKkKyz1LFf2U=; b=W5s9AU48HEztfQElEyALu36g8EOW7LFaYMund+6XxQ8krzuJZvQHjY+4CmFz/BxIUY F9ZBJ8jCqFvrYHQbQE/jwE/Yh9nz2xwfuyaalGdke4Ct+51mOrNnVW/zsfCpTQl3AaKq d7RkNtko0/CDYHZ2tB/PI3rJRCwYnAGBIPnmywAOdXHw38A5qzlPq/gb7e9ad9ohsZGS Ru/rv49XewJpWuW12LoxFhW7GTXIO4SMBCdQCT4AGEDw3fIgGRwmN+sk1qWlTRylv00k feZnuQv1YZkyBNP/xxHlGHYPgK8u+nrYzGI9zVoynbnX3Dx0YCDaGQ/dywcIMlhPh87S eTRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753954089; x=1754558889; 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=VdUDk8PNeElBQFIXVeH+4JTV5pz3z+NOKkKyz1LFf2U=; b=hloyoCdu+DySIaQEhp/4Z35udMAr1bA81VTrWgfxiqgegN7LdXsnBY34ULtPuZL4zR v3iTRiWqBDjxg0FwEnMOzvGCk6GcyfY8sRbZT/i6GufRcWJQ6KjhfEIgCfHSBX8ZFMtv pd3bkYZ8MaiaFhNRu/Ql1RccjU377zExu3appiCZipEzYtX0au9m9zQ2608xsVXKgY73 DKd+TofP40Sc8b8rVQD157hi0BbsV5XubCOYlHhwvvKc/f8ZRbpJap6Um5dmUXVuK9SI DDIvVPV01A+lZVMg0MmBxWGdHaZd4dPKyWfyNWbfnyXEBvHmu9uKwMKxlltcfD64EV81 WexQ== X-Gm-Message-State: AOJu0YxpCD5wrWNMrMU++gIUSlX7HJgPHOB8f3bTXUVrc3Fdz+mODR8L hujp4bC+cYiEMiAbA2ggffw+1Gjp/DAclVeLmtC+atXKoLRbwb+M0UXoyDeIIr90 X-Gm-Gg: ASbGncs/bwsKkf5DuzSj4KZfYehHw7aNRbbrAkZlDQFsrk1VrXbMGZ4NpRzV/4pBhGm lipIOMHvz4fn169KH23A4dn+1n919o6GS593BeWUpoEOKnF82Dv8EeeEgCEwnCOKtg0RGGi6nyr CSkXC4YVSyZAOiHrZ1L9hzfmFWzuSeFIPe3Vj504701YLHD7HnYOy2JnXlJcEfQc8NWjb5sApIG s1/b6/aq44WGqq8lPqa3RTcM0jAJv+m1Dzitw85Udl46CwQZFPS4Kupo2vlOWB6fr1qQM6CKwDS hVKM9o2XxUtQQ5pvsZQ/xA6H3pEI74gOF9IDzKbnyRun+NN8adiQ+374o5/+NY5jTjOG9U5cbF5 lfoqxmZr0XbTO5Jr+5qtFwqL4/DkokumHoSCmZZ+A8TA8oS6Lklk36KP5ENdKCaRbY17q3+eNrT 4WhXGUfeG2dsvtw/prLDvqqw== X-Google-Smtp-Source: AGHT+IG6n6aFGbUSrsHSAh0aU46l2diUOlWIJm35CRQ1UhDTmou18GJKCwrhit53VyT1kWPxPp8SOg== X-Received: by 2002:a05:600c:3e15:b0:442:fff5:5185 with SMTP id 5b1f17b1804b1-4589e8745e9mr8944225e9.6.1753954088600; Thu, 31 Jul 2025 02:28:08 -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 v12 1/6] altp2m: Drop p2m_altp2m_check() stubs on non-x86, move prototype, and guard uses Date: Thu, 31 Jul 2025 09:27:56 +0000 Message-Id: <44b4b60854cd7db6d529ff23bb228e9ac19a2a75.1753953832.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: 1753954107135116600 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 subsequent c= ommit 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 Acked-by: Julien Grall # arm Acked-by: Tamas K Lengyel --- 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=1753954114; cv=none; d=zohomail.com; s=zohoarc; b=TNRJSluMO8+dJq7FzjVx/MW6oZEW4RI9r5sebry8xO/49nt4YYeqGJ09h+Tjg+4kmbUyiXg8YZ31ew8/58EOqY3BSlVDqsza2MJ3EzY7ZWtETG11x+ZR3UqCxrSWMYcMd8/vfQSdKSey1jxVy5DJYE2HJRw8s20NYZyWKEpehXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753954114; 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=vSeD66VYY/7lq9b03uVb3nrDcwpq4lY3KXbmJLU83qc=; b=U+VPgpAw/UucwLrPYBkvFcBzr9FVkZ+xz7w+0S4O590bMBvwzoUckC0OBw9lLMMyTiqhCRAIwXh8ALnECt15vpduwTANcdxD51T/q1GrKtjXfUeQWgU/M1tfmy59fOcukR2yu0TrDEyVObGDvnSLVJB07ihs7a+70m8LN6wTzVQ= 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 1753954114447201.6037404247529; Thu, 31 Jul 2025 02:28:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1065151.1430510 (Exim 4.92) (envelope-from ) id 1uhPaA-0000mM-Vf; Thu, 31 Jul 2025 09:28:14 +0000 Received: by outflank-mailman (output) from mailman id 1065151.1430510; Thu, 31 Jul 2025 09:28:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uhPaA-0000mF-S9; Thu, 31 Jul 2025 09:28:14 +0000 Received: by outflank-mailman (input) for mailman id 1065151; Thu, 31 Jul 2025 09:28:12 +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 1uhPa8-0000Jb-Hz for xen-devel@lists.xenproject.org; Thu, 31 Jul 2025 09:28:12 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id acc1625c-6df0-11f0-b895-0df219b8e170; Thu, 31 Jul 2025 11:28:10 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-455f7cc9362so894745e9.2 for ; Thu, 31 Jul 2025 02:28:10 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-458953cfcc1sm60905485e9.17.2025.07.31.02.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 02:28:09 -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: acc1625c-6df0-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753954090; x=1754558890; 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=vSeD66VYY/7lq9b03uVb3nrDcwpq4lY3KXbmJLU83qc=; b=a+G1jc9GkMa6bLFx2hkQQMLHck0kTKTFj5+TN2kX4hPxdGj+uJ7SjSy5Gsp7tojQpx QwU8dtl3za/GnBUTwuSVxSAV6Y7S5pRMZ7RbeVfXsWbvkoZ9roU0jrxQsIy7IS0HlhyS fHoDc21iNChzU/6L+Tl/bz7m7aXKQduHM3C5YcmNKScUPT0RDMvsPGV7+gXTIsVghwIL tXCAzSQrq/XIYiJ1YTTQ2qdoo/8UdJzSgV8a6hg3aYw/v+jFgtxhj5ipKPCRCm+/AMuo 1L5zbWUfSHTMkPnbBOANVSydpJX6Fh+SQMhupWpqKl56ytgzuOI0FJVIYEPOPAspLXNp v1hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753954090; x=1754558890; 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=vSeD66VYY/7lq9b03uVb3nrDcwpq4lY3KXbmJLU83qc=; b=O9m8B1g1b3I37meALw0YOQTv6HwGU29g6dE3OwmPs2jzY+TlmU4azyrMcFfe0kwP6h HVzq2fGucWLwPc9AAiUG/FVYe7+Rtr5VDORAJiXZqLLyX5hszdLBJ5Z628Omke7Vqv+V 1THVPbZaYCHWDlaNkwMeURKIf8gPBDBBTCQgUCHM0gHavFOqTnR7eq91799zzftoh278 1y9394vDVMCEQi0JBBhO9sDrKuBq6LzcZWzsTcwNg71nQt+k3T5bVo+GsSq9OmMfMA1J HXtUONyDEIG4gB+MVFHKfGwkSgXlQUuDrl/G4MJ+s1nd3v0SucaxJ6cfwZ53zyhTUOpZ 6tUQ== X-Gm-Message-State: AOJu0YwbE2uvxE+rfc9pd7htETEz0f84h/jYP83shDEU+qsjNj93W6Ro tQh1nOUKTxcZ96BkOn9NFHMKIXw4i0BYq66YEk5VVdptTBDeMnhSMymUDQm54EWb X-Gm-Gg: ASbGncs2gMRciNRlNIE6Gk9iiSsFfjWPAkfOifY/6StJr6yTncqC6CCYSryHZU7e06+ wYDoSHmsS44Ef4ixyGAb0fU0JF6EtJXrQT/qXnjKxH0feXo4Z8Ooz2HiQnNQRoYzy6U0nd4C57I 4UiDVQnMVjE/HAFokWhwRR9xtlyxuqQPkzNxAJik26IbE0gJ3Z3ugd9jUzwiGj6f+RVRleMgvTj GWnEd3V/embyS6Vy2OoHMFF77QSae83EE4IVgfDxx1o46x7YB7XwBGW/Ty9wV/tdAoGnMCdKKSi D4ovr5mIPyFOnr/dp9CoEt0fHyZDDQNnYQZ6b7MAQYb18nwKx3Yhv2iKc18DkcIQ76g4hsjja1o I5jt8+nsKIjMDT8fup/P7UKzobhszkY2mQHicFfBSc9k1klWuguKRJscaMmre418mt2J9SNGoZ6 uduO7xoi1g+GpYS0AO+yN4GQ== X-Google-Smtp-Source: AGHT+IHEDAoM9LSTKD8g+d923r70X+1obien4WkirgBSal8//wNez3rXpRXzPMAk+Zm8LQ/gKmkWVA== X-Received: by 2002:a05:600c:3e15:b0:442:fff5:5185 with SMTP id 5b1f17b1804b1-4589e8745e9mr8944495e9.6.1753954089628; Thu, 31 Jul 2025 02:28:09 -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 v12 2/6] x86/altp2m: Wrap altp2m-specific code in #ifdef CONFIG_ALTP2M Date: Thu, 31 Jul 2025 09:27:57 +0000 Message-Id: <2fc138bf8f1100b6347b965e16691b9d6e3272fe.1753953832.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: 1753954115282116600 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 Acked-by: Tamas K Lengyel Reviewed-by: Jan Beulich --- 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 | 31 +++++++++++++++++++---------- 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, 82 insertions(+), 12 deletions(-) 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..5ce0dc936f 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 */ @@ -932,11 +934,6 @@ bool p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsi= gned int idx); /* Flush all the alternate p2m's for a domain */ void p2m_flush_altp2m(struct domain *d); =20 -/* Alternate p2m paging */ -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); - /* Make a specific alternate p2m valid */ int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx); =20 @@ -954,17 +951,29 @@ int p2m_switch_domain_altp2m_by_id(struct domain *d, = unsigned int idx); int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx, gfn_t old_gfn, gfn_t new_gfn); =20 -/* Propagate a host p2m change to all alternate p2m's */ -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); - /* Set a specific p2m view visibility */ int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int altp2m_i= dx, uint8_t visible); =20 -#else /* !CONFIG_HVM */ +#else /* !CONFIG_ALTP2M */ struct p2m_domain *p2m_get_altp2m(struct vcpu *v); +bool p2m_set_altp2m(struct vcpu *v, unsigned int idx); +#endif /* CONFIG_ALTP2M */ + +/* + * Common alternate p2m declarations that need to be visible + * regardless of CONFIG_ALTP2M + */ + +/* Alternate p2m paging */ +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); + =20 +/* Propagate a host p2m change to all alternate p2m's */ +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_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=1753954115; cv=none; d=zohomail.com; s=zohoarc; b=dxOzpkXFo7oN1DT29g/nmKNKn/7CRXdfaC8eqLsGLpUVW6jNnnER/gAZVXktQecZCKhRK2o9mMqRwFqre3knwTeninGv/R5K+uJKs/1YJ71TH3BJvWPJThhDBVdMvHOx/p5W3gAEbfbIgsYCZKZD5M0OAiFXaP1+95lDHHlSUYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753954115; 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=PjoD2P+3wNjCYfSx0cXvlWq3oxFY+cd+qHnmaUvvT5M=; b=Kp433JF6/uZ2QqgkE1CMw7EhthdBfVbHM7cj1UU3P1fvPxIPLPre1oB1MfR+40s8q5vzrejgegB+YiYKXwygZ8MPEvv6nq1rZ1zHegkagsxdhSzYwe3VjQGbo1aK6Ek8tiduuV6speiAeO68bWEhtIL8yoz9zgx3RsrKPQszuC8= 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 1753954115857585.899104813678; Thu, 31 Jul 2025 02:28:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1065153.1430524 (Exim 4.92) (envelope-from ) id 1uhPaB-00012Y-VA; Thu, 31 Jul 2025 09:28:15 +0000 Received: by outflank-mailman (output) from mailman id 1065153.1430524; Thu, 31 Jul 2025 09:28:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uhPaB-00011X-Od; Thu, 31 Jul 2025 09:28:15 +0000 Received: by outflank-mailman (input) for mailman id 1065153; Thu, 31 Jul 2025 09:28:14 +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 1uhPaA-0000Xx-5u for xen-devel@lists.xenproject.org; Thu, 31 Jul 2025 09:28:14 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ad5793be-6df0-11f0-a320-13f23c93f187; Thu, 31 Jul 2025 11:28:11 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4589c1f55aeso1083915e9.1 for ; Thu, 31 Jul 2025 02:28:12 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-458953cfcc1sm60905485e9.17.2025.07.31.02.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 02:28:10 -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: ad5793be-6df0-11f0-a320-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753954091; x=1754558891; 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=PjoD2P+3wNjCYfSx0cXvlWq3oxFY+cd+qHnmaUvvT5M=; b=kchWp1GWHjPAZgzHduU3Ymk1kCM8ZUmTw6ZLjorbkcQjHCBHJHypJTMlPBSchAPPX2 cZay+jwk+D7zIIvYlpRdpu7wOUZr0A9LN1dES++lw0FCv7WSvof0pqahd9OHF317g73b SYOfAkXqPlSbqggKM+K9QPZnzWQrR5qfBj05VBwcvwOjNKHhPNVw+2WQP9PnOei+Fwor 4tn0tmDCovX6lCz8+g+TISOlX0PFvIAbHaAPy7nkbuexMvjzg29b7euTWH5nf/kdRJWU uXjv/1eczofQf3j9rw04Vdfwdnl5/Px7pTXXlTs7wRlQHQak9VY5E3+zHazpzJYOFSJY Rnuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753954091; x=1754558891; 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=PjoD2P+3wNjCYfSx0cXvlWq3oxFY+cd+qHnmaUvvT5M=; b=ATMyoesSBYgsbsaS7wJfovAQybjahr86lB/Gv9M7ZXDoEUaWpwbj2uiCxn+vfDhTYt yjd2Kb7P1o2mXnEeHqSQtiYLRon/XQtlNh3sDMz89hGjmpeAlFgOtGEbLATnbfZ37RWR as7ouuh0R1TPmjWCXaIEpz9I9YzBSMp7v0eNeN6JYiFoOc4agoSJhoeK19avsWHUGpaf jFZR5pY8DVK0aeentbASSFZJQXMxGbImgkSwdLcZwoy6sD2MURW7tnS2sskVwNeehvgE dd1/tTPGYp1LKSUBfDMOfOiJIvvOhMLGom/toxExNKLYFknyC9dlpZJH06sHTxjaIBBh SVCg== X-Gm-Message-State: AOJu0YyieM2STN0CaIAjvS07XGDRsScjTwBkkI52+p5DE0FEKzqm6zJe RKNr4lkvUAkMle//v4uS/+G5pb+hOngFw1qZd07g9YmLRsB2+Bp2eUDBTQ8dKisK X-Gm-Gg: ASbGncs9up2ktAbD9iGnEARw0xyLub2UWnFxVq7CvdZkidN2yDammLomuiPfXo2odLV Xc6k6RgMfgcYefCJzUdGFFuPnSxdEmaeXnUcOLFQxc3L/3Ry7oSJ9OqkNQD6rB9UfTIHmuzxk/o g8qXmSzbgGWuP1RfW22wGVKBzXxgD0VcSMQzSURUHX0cRW+7P3eeOh9Y9yd0CaEkw4mc3eZpEx4 SaCtwyDiEdkj+/K35GJc78XZXYmpsYsHBsJEh3Mw+tZOfo8cJmhe5xoEoDpVDdwJ+DexJOgKXXD m+zxRi37eRMenISmKtG5HybO+PPZbskEldy7BaWjRJq6ps2LWAkf6UVi1fYBUvyAgWvwaY1Qv3X JQrpwDrjE9t5NohK8lnlImUBiBk/c/89rwmj0Enfxjf7wtgXc6AdABRF6F5ohZ9wO/rFATOZ3Iy ITQaO286QOp3hRniRVnjvX+A== X-Google-Smtp-Source: AGHT+IFE42O0Q2I03F/zd8FXLOCSlUrOZY1rpSlgzu/DxYc+QgmyPZQVl69FqqkRkmgOE80eDCXgcg== X-Received: by 2002:a05:600c:348c:b0:456:4bb5:c956 with SMTP id 5b1f17b1804b1-4589df74a34mr11657105e9.7.1753954090909; Thu, 31 Jul 2025 02:28:10 -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 v12 3/6] xen: Make the maximum number of altp2m views configurable for x86 Date: Thu, 31 Jul 2025 09:27:58 +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: 1753954117238116600 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 Acked-by: Julien Grall Acked-by: Tamas K Lengyel --- 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 5ce0dc936f..3b860e30c3 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=1753954108; cv=none; d=zohomail.com; s=zohoarc; b=RfyRaUwRW2G6SPParEbam4AibWTXB4kmBFPnPSMmruZIOc6OzkiAwwPb0MgsRGXuNRHDu2r/0y+QB0sKi8ypEBNPRpjzOpg20yANzfA0KbwynAlZktYRTI+rEpL/OwmzNDPDxB+KU78+60AThUMi4oI6VAqayu2JKAisQ9gQMD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753954108; 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=h4ym6uea7ffTLrCmmZbbbOhI60s/uiV34TnE5t6+/CREeISL17048N+6tceU+eD/PUqixYeyWd9hqv43YCuQeO8EdeMWJxs4H/E1W6fSUA70+IjdyPlCYP5UBxAxzytxH9yqOIh8jmmKQm9wZUyPtpWKzK0ye7NwYCQJ4g4W4IY= 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 1753954108978675.936781528881; Thu, 31 Jul 2025 02:28:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1065152.1430515 (Exim 4.92) (envelope-from ) id 1uhPaB-0000oX-9t; Thu, 31 Jul 2025 09:28:15 +0000 Received: by outflank-mailman (output) from mailman id 1065152.1430515; Thu, 31 Jul 2025 09:28:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uhPaB-0000nx-3q; Thu, 31 Jul 2025 09:28:15 +0000 Received: by outflank-mailman (input) for mailman id 1065152; Thu, 31 Jul 2025 09:28:13 +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 1uhPa9-0000Xx-Gj for xen-devel@lists.xenproject.org; Thu, 31 Jul 2025 09:28:13 +0000 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [2a00:1450:4864:20::330]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id adb4b713-6df0-11f0-a320-13f23c93f187; Thu, 31 Jul 2025 11:28:12 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-456127b9958so885205e9.3 for ; Thu, 31 Jul 2025 02:28:12 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-458953cfcc1sm60905485e9.17.2025.07.31.02.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 02:28:11 -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: adb4b713-6df0-11f0-a320-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753954092; x=1754558892; 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=IvMeCcY46XUGGa3JWUY3L9lqJVFMzCEa1IGpXOn4B+uRRf9iovjxl0OnPBNlu9h56e T7nyO/8VDgU72nKAIkw8ya82WXTs0uzE7P99cEZYd+Q87f5b4pD9g3hqHz8sOaFGQqtg XBRvc0srQGAAAEV9MnQkJu+vvIy+0+/wrYCaKP38xXhwor/SSoNflCCFCml4dw+08oXE XmpueMPy2M89qb/0XvzekZF0NxI5sNZwNzd9pl9t4JubIe52hEPTfXWvcUkyz1gWrnvS /VdXXQPg+lzxHHaeUFAlu9QRlI8hJcf6g5xxWbXYkw4R+lu+K5VKZy0YnDLjuG+8uA4Y T/fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753954092; x=1754558892; 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=cIBvSwx1ao9hGvBrIl+IonwVj/xhuEseUt7qwLYRYZlqrFbRSfdwS104UcSGS4/Ehp 5iifVlc8NBnWvXGeJ8Y1PyBlOUqXgPHMD/o5q36uvySe8Pu6dx+D44fjvzMTkDIL5R43 f2eWeasF1cr8+lONv+BCi0jBGCgd7eXj7mIJPJWjZb3TTDNvSY2NYKHIW0wa3+iz9x3v wrDui2ENA+SqMzlE6UULlRlMO+ezswLBX7oHf8oTf/Mxccnfkwba69GD7lKSgcdVH7Bd zcHTRqxoL6MOqRDR5plhlCk4MakPxSacQbuo0emn4SK29uhtZgcoqpxQdAJ/p536cbSS /Gyg== X-Gm-Message-State: AOJu0Yy9iQa6B5tbWUXoFBftYiHmWMPPf2LjiMLEg1vQ3k7HEjdycRYo 56g2yiW4rCNEQcjVC1OThw8WgaRyWjUFOosDoTRkqUWqP6yx2VYJ4l0huVuHb3xb X-Gm-Gg: ASbGncuLvtxFaM9ppOGZSIV8khH1JM/Q6cGGU9EBBWXk0SSupCnXEp1JI5jOz8CATLs +0ldUqOBMDaTgzHxDGb0ig7vzMw/LP3oDXGOngpDl3C0LAGJ0EV5MklvDCgmZzbKsEZ2t6PV2XW xeGKhowOvWwnGyc4r2wvAT6jEm1rD9xjkLpiGSdNr5TKuwqzx5Mvh66vMaZl/6aPpWFKNUmrqxS sRHl/vlYPoqI8B+M7rbLAWnmR0ULugQ7aiDFkAhkOPxmKk+PU5Yn+BiGrru3jGTv0Qgwov0pVQE SDVIDYoo+XTSsxrbUxS/W8JPbtYR8pAoGPbQ/P90gLYlH+KFgnBih9JAD1UIC0rr8XGwJmXEL4g 3183Mm0BaeZPVjBUnBlIjYNiaENnccktK9oignfdKzN/3WzfUYRsabtzXdOQfyd9Z/J43BOlVQG OjCT7J3PfKfDb9xPKuJb9EMQ== X-Google-Smtp-Source: AGHT+IE92TItSzbpJtRrZEE5XTGgQz8CClAbi63Z8iaaR+liLnsHNYGp2qhWNnPjKUw7fGuCCkEp1Q== X-Received: by 2002:a05:600c:1f94:b0:450:d5ed:3c20 with SMTP id 5b1f17b1804b1-4589956fdb6mr20914575e9.6.1753954091679; Thu, 31 Jul 2025 02:28:11 -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 v12 4/6] tools/libxl: Activate the altp2m_count feature Date: Thu, 31 Jul 2025 09:27:59 +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: 1753954110946116600 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=1753954112; cv=none; d=zohomail.com; s=zohoarc; b=h0MePEfSBZprbLZ3/gyq6zxmA1x6ZsWTVi/hJYzWYVwmP1lTynqFDRVpBqHZkAczHcju7+nXcgYnqr6m1EdA0OsHQGwIS3fmyP+tDanRGniuLKZQbp6HKL1NDnaDFkSIiwBpgZztzOLT2cUGudIUjk5u4rIkH4lOqREAosALzaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753954112; 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=Bg+7HN5ZN2AAfyoSpbiw5A9e5iClFLj+zKGkQ00AMGG5Yo0InEhm8ypWlWv6zhs5wzv4ujA1tVxzEbcq2GsmOSVzXLajHEHybijddcRNN+NTLqvbln1oA8gd3zkVFlMFMBiDqfiCzivZqlzPFzYrBO+NMbTBOdranAAHRvYMQW0= 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 1753954112157335.09210880301634; Thu, 31 Jul 2025 02:28:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1065154.1430534 (Exim 4.92) (envelope-from ) id 1uhPaC-0001FA-Nn; Thu, 31 Jul 2025 09:28:16 +0000 Received: by outflank-mailman (output) from mailman id 1065154.1430534; Thu, 31 Jul 2025 09:28:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uhPaC-0001CH-FF; Thu, 31 Jul 2025 09:28:16 +0000 Received: by outflank-mailman (input) for mailman id 1065154; Thu, 31 Jul 2025 09:28:15 +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 1uhPaB-0000Jb-3E for xen-devel@lists.xenproject.org; Thu, 31 Jul 2025 09:28:15 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ae68d25c-6df0-11f0-b895-0df219b8e170; Thu, 31 Jul 2025 11:28:13 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4535fc0485dso1331795e9.0 for ; Thu, 31 Jul 2025 02:28:13 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-458953cfcc1sm60905485e9.17.2025.07.31.02.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 02:28:12 -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: ae68d25c-6df0-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753954093; x=1754558893; 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=SjLvpVHtRd18lhE9Txlxga6WzTJxYWCaHdYIS554D4rS1DZQtXKkm3vYWjLnH8lHYP A/7VJKvXciJaPPMBxZHt5APMXdYn4QtoZuzyWWj8Tp1xJ/2SLxDlMLu+tg/evz584qRq YUP3zHOfQ/DaKxBBmW5SSWSNXlnK0BoClo3uBNypKAwiwsc+tfRhVuVrpxR+s/+On5qU Gna2KciGbTArZadJPiMvpSGye/pasSgbBv5S9dZtdPSHEjy3MeGNWdglVWpKaAxw055c DRpF1BOIaKDP8+1nkn0/NDihQGu/vlMGw+1ot7UpHp6virCQc7/XjZa5NG/JWPHf2lvA /B5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753954093; x=1754558893; 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=FF0//g/WBvhErcG1cb8euvIqxc7mzwLh6wb26T7NkIe5SeYvBTdNRy1hoY69ASZZlj yv9LwSIJsHrYU6SmXYvdXIyuoGAKHpRlo6Z689i8sMa6RcDb6RlMkPM7W0YLGkwZxOCv wwA2y1dgvnMonEWG/swXGtVbbzU60WEA28PZEjqzMPmA2JZ7ecAn2DA0bI8YTFZkGuEq Xys1ajrHgrtT00aZkX2HSZchVf0c3iapB9MO6PjMiydz8HA/7bybGLN8Wb06udN3ILne UZ0zqsqAygyTDafmbjWsWCFqAqEgWwDQzZok4oqdqsiWy/G2uSPnzvaE95Fy6Tu0JkV2 Y28A== X-Gm-Message-State: AOJu0YwOL7RT+f35uo6wi0K9ZgBSSrSOFgZw+D4B8I/1nl8sOmqKPBd+ OPr3vO86blODBTvHcFTVTBaQSUuShUq6BdlmHe8crerBUBOMHic7x3aoEv9Vwpfe X-Gm-Gg: ASbGncvb7nfmFpxM6lSeTV7UcLXCYvjGQfJkvuH6cbQW8hiMR5RjPleMwkYwZ6WdCkV nD+PAgtd/ErSrvJAedS8O37cHOjcM9EQDsYIzkZWd4kpynIwaWuUdfStDvbdhHUdQPfwGAyJKGL frbv8AinG9krhv84ynTheFHuiegW6ZgzH5HdmU3yMSwNrPmGhxjKqLf9KL7RYYHtkVZU9cymL4B ftAzc8ygwLIrIGLSzpY5JNL2FFK6sWn4eVxxTJMCk8tbGwvzNnCoReHT35u2d4Z+JNACvEKAQpZ Aktnek02S2NJIEwaYy7c8QOTEPHp4JkQ9B9JW68ywO5Z8Y1g0C0p0CDUb40HPgouvFe/LNn0Jdr oRUOILwHSABEqiCXONBAcw3OFBQryeDz7h7VDBsbv6MvTscSgzLExoV89oYFsManEK085kgPiaC au6u5hgwjeD8jNGYlkurBITA== X-Google-Smtp-Source: AGHT+IEn8oOmYQANRYTAYZUH6CiTUYdF7AujZG5AvgjD6VIU1gHdiyRGW9wGYbdQaIEriGhMgugt0w== X-Received: by 2002:a05:600c:3b95:b0:43b:c844:a4ba with SMTP id 5b1f17b1804b1-45892d05354mr21963705e9.3.1753954092602; Thu, 31 Jul 2025 02:28:12 -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 v12 5/6] xen/x86: Disallow creating domains with altp2m enabled and altp2m.nr == 0 Date: Thu, 31 Jul 2025 09:28:00 +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: 1753954112906116600 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=1753954118; cv=none; d=zohomail.com; s=zohoarc; b=cXjdGD9rI8wJiAD1CFoa2XKpohYsHS71+aRlkvIHpHb8gQ13pHOzzwgPw/ZRu4BhfVPoRy6T9ier/AvL11CrEBPVl/MGBu08IH5OT4XRLTPmuGBin3P+silz752oM8gq+Z/W9OVku42TdmuP014BteABx3yec+z7JQ/WOht0vUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753954118; 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=Gnrv4WKeM5aRphL1Vop4ivYIMDUCIDE6qEF40z/mP2ItbG0kXiXT8II4JPCqvZ87xgaFMGOHt02ckrf5scNfWp/LoClzsS2bILf4AELN7Qm2Fl9cuflEfRg//mvkqRKbMrOgRNlm5HzBzB3ejx8Uev09E+sDiKjC2tAPBgPLrDs= 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 175395411822082.14544945883131; Thu, 31 Jul 2025 02:28:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1065155.1430549 (Exim 4.92) (envelope-from ) id 1uhPaE-0001hq-1M; Thu, 31 Jul 2025 09:28:18 +0000 Received: by outflank-mailman (output) from mailman id 1065155.1430549; Thu, 31 Jul 2025 09:28:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uhPaD-0001fy-SG; Thu, 31 Jul 2025 09:28:17 +0000 Received: by outflank-mailman (input) for mailman id 1065155; Thu, 31 Jul 2025 09:28:16 +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 1uhPaB-0000Jb-UO for xen-devel@lists.xenproject.org; Thu, 31 Jul 2025 09:28:15 +0000 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [2a00:1450:4864:20::32b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id aee76141-6df0-11f0-b895-0df219b8e170; Thu, 31 Jul 2025 11:28:14 +0200 (CEST) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4562421501fso382625e9.2 for ; Thu, 31 Jul 2025 02:28:14 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-458953cfcc1sm60905485e9.17.2025.07.31.02.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 02:28:13 -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: aee76141-6df0-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753954093; x=1754558893; 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=ANw27iK/hTI2fp5jZSS9v5CRFUlK/ASDSZNmrR27F94k22d4f/D+9XlQ2wsg6qGi1q 12CdSq2GJgxzjh3oqlTR0J/tye74GdQBvYrOwDmyGuWeF69+sZvVV/EIIMc0JpSs0Fq8 JCJ3HMSjpXeG8KzHjcn7MC0CG59XsvQroDPapukqndFVAnp5utO2hr72zdrXXqFmTBt/ 4RZxYYhvrZAgb66L7tmE0mbuN/ng/X4NS0weE0PiODSJwnozNs2IpRAEIqlMBWOTkRh6 F4ILnRXkJkEm60SdC7gtWCW5neyfnG5DpofnHy5qgK28Tfus03HoeTIRfl+vWu/PiqYj v0Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753954093; x=1754558893; 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=uu5ZpLcOYg7TBzXMnOfNdlJMwF3GuO5e4yWXfXXSnygYWnRV1XEtVDtNEpbaIJL4VU j6faAkrwxt+2TVwbK+tC1/JDksMEluq3nNY0VvoyjysM31R8k/OdkTFtpsRCfycGwuvN fUf2Ehb8oAucqzcZgl+hkbQm4JgmbiF2XuurB5WHT+C8x13MROBmIinbOUboXd2bPfTL OI95nXTnMVqMjuz9xnvbFrZkfdEhaxXQ9ql70+N/L4Rz4kw/fRXCxR+evvc/+1ZWErsX fHCQpHL6y2kbkEEFOtzM3N9KbQ7SgN7lv+8ucqKQ+nP2Rtq1KtceqO++6YRCH0CH1M7B Li/A== X-Gm-Message-State: AOJu0YzM3xicyzGSHktXJ0qJxYXZIhYyT2pDZSMjoIxkVtTwbfKINWO1 vWnp1hPEgVkSQ8fQyy8+gu17bnsSiUdf3/s5MQEuDFYDzPNTYU0PKCCY94jDVPGe X-Gm-Gg: ASbGncuzaD0pVmry/t+x96kP2B4STQVi3d+s3tLVcj4qRiBRqZqiner2Oa/IjP0hyJs mzxK1lygGIIlbeleSoVpGWGhdQkDmnmHsqMiKpFD/4Y+3hfESVf/Co81LZQh4rLz+BCEB76nLJa hg2NYSuQi0iTkiuh6kwXpHR37iH7XEQeQko66PJjvVNFptZb3Lj8Nbq/YwW4RwlOsxcMrPc27XZ vIjgTUCtR11lV83WKplzecaKN5PG0jYtniO/wCu8xj5AEB6ZQX6G7yPRzckV2oecisJcPj4f6e0 ZSbahOhvFqwTy5b9w2/XfTO8N5WgRptgUB3+I8IbXTWQTPiSzBc3cWjZoKf4TvGx6MDQNuKSy4r FvyMkd60FY0q4U7dXh0lNB1NfGph183h+Ntcvu7PiJIqUyiTCwBXai2NoAiq4h0r9DrkW2JPSMO T9J1ZubSHBQEWXZwgmMvkTZQ== X-Google-Smtp-Source: AGHT+IHDauYM3bbENvt9keKItW18IVWr4ESxR7aDibVq+DmxUOjeSZ0ItRWgM3AyJBNrPkDHTe+hwA== X-Received: by 2002:a05:600c:64c7:b0:453:7011:fcdb with SMTP id 5b1f17b1804b1-45892bbf504mr26785165e9.1.1753954093453; Thu, 31 Jul 2025 02:28:13 -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 v12 6/6] tools/ocaml: Add altp2m_count parameter Date: Thu, 31 Jul 2025 09:28:01 +0000 Message-Id: <29eb9248618eb61c41c304a4b50bdd5250094200.1753953832.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: 1753954118984116600 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