From patchwork Mon Jun 3 11:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergiy Kibrik X-Patchwork-Id: 13683635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7555EC25B75 for ; Mon, 3 Jun 2024 11:12:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.734816.1140897 (Exim 4.92) (envelope-from ) id 1sE5bc-00018a-8v; Mon, 03 Jun 2024 11:12:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 734816.1140897; Mon, 03 Jun 2024 11:12:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5bc-00018T-4d; Mon, 03 Jun 2024 11:12:00 +0000 Received: by outflank-mailman (input) for mailman id 734816; Mon, 03 Jun 2024 11:11:58 +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 1sE5ba-00016a-Hs for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:11:58 +0000 Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 170103e2-219a-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:11:57 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id E9B4A315F7; Mon, 3 Jun 2024 07:11:55 -0400 (EDT) (envelope-from sakib@darkstar.site) Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id E1FF9315F6; Mon, 3 Jun 2024 07:11:55 -0400 (EDT) (envelope-from sakib@darkstar.site) Received: from localhost (unknown [185.130.54.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 0CA89315F5; Mon, 3 Jun 2024 07:11:52 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 170103e2-219a-11ef-90a1-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=md4/Z52UulaNXfs7DDM6MqdCK uKZsNgFQ+L4Xd1y2gc=; b=xQ5QuPr/nIZwTMBYH0J0WoqHEmpCXlUZni/x4ZfM5 JtszSZP01QQEGfglBenuK9WZ4Gbrj07+g/3f0jagYh7ojJAExxJlnd3pOBa6mk0I dN8kib1imh0nWiGQ462buSFsyUpUw2TV3J0yO9tyD+U9YobK/5m8OH62OcukD9LA 3U= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Andrew Cooper , George Dunlap , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Jan Beulich , Stefano Stabellini , Xenia Ragiadakou , Tamas K Lengyel Subject: [XEN PATCH v3 03/16] x86/p2m: guard altp2m routines Date: Mon, 3 Jun 2024 14:11:49 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 14E00040-219A-11EF-B614-8F8B087618E4-90055647!pb-smtp21.pobox.com Initialize and bring down altp2m only when it is supported by the platform, e.g. VMX. Also guard p2m_altp2m_propagate_change(). The puspose of that is the possiblity to disable altp2m support and exclude its code from the build completely, when it's not supported by the target platform. Signed-off-by: Sergiy Kibrik Reviewed-by: Stefano Stabellini CC: Tamas K Lengyel CC: Jan Beulich Acked-by: Jan Beulich --- changes in v3: - put hvm_altp2m_supported() first - rewrite changes to p2m_init() with less code - add tag --- xen/arch/x86/mm/p2m-basic.c | 9 +++++---- xen/arch/x86/mm/p2m-ept.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm/p2m-basic.c b/xen/arch/x86/mm/p2m-basic.c index 25d27a0a9f..08007a687c 100644 --- a/xen/arch/x86/mm/p2m-basic.c +++ b/xen/arch/x86/mm/p2m-basic.c @@ -128,7 +128,7 @@ int p2m_init(struct domain *d) return rc; } - rc = p2m_init_altp2m(d); + rc = hvm_altp2m_supported() ? p2m_init_altp2m(d) : 0; if ( rc ) { p2m_teardown_hostp2m(d); @@ -197,11 +197,12 @@ void p2m_final_teardown(struct domain *d) { if ( is_hvm_domain(d) ) { + if ( hvm_altp2m_supported() ) + p2m_teardown_altp2m(d); /* - * We must tear down both of them unconditionally because - * we initialise them unconditionally. + * We must tear down nestedp2m unconditionally because + * we initialise it unconditionally. */ - p2m_teardown_altp2m(d); p2m_teardown_nestedp2m(d); } diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index f83610cb8c..c261ba02db 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -986,7 +986,7 @@ out: if ( is_epte_present(&old_entry) ) ept_free_entry(p2m, &old_entry, target); - if ( entry_written && p2m_is_hostp2m(p2m) ) + if ( hvm_altp2m_supported() && entry_written && p2m_is_hostp2m(p2m) ) { ret = p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt, p2ma); if ( !rc )