From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717412884; cv=none; d=zohomail.com; s=zohoarc; b=KnI8xKLSgb0HiKp7Gug3sDA4s+Or4yuhh9SHBGlH/e4KZOunRgS6Z9rcW+e7D9fp3nBB/dvA/D1kuIr4/32tmTVO8IeXlyXTMCv7W9UwcgfxUiu+vx7ljioC/kKj9B0ehkerU7hfLQbGIiOLpqBTZHZUdPRk41HbQ/XJeQ7FNN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717412884; h=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=3odzLgaXLrw028eUZtro4lyei7jeNpZtZCqyQsygZrU=; b=NvujNop4fF7XPq5VNiHRIc2S2gmJx9OA7eNO7syZpkz6Uj316HMxK0I1QygyHd9inP1iULGrmT/1h4oRKzuG+uqnnqpSmBQM+OkFczX7S7is6eQsqmejUavlGnJX69vIkP9IlNgzleL6f9Q8s4flJGkraLAxBhEymR+jbPY1Yi8= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717412884486941.6039752246508; Mon, 3 Jun 2024 04:08:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734803.1140876 (Exim 4.92) (envelope-from ) id 1sE5XY-0007IF-Gj; Mon, 03 Jun 2024 11:07:48 +0000 Received: by outflank-mailman (output) from mailman id 734803.1140876; Mon, 03 Jun 2024 11:07:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5XY-0007I8-Dt; Mon, 03 Jun 2024 11:07:48 +0000 Received: by outflank-mailman (input) for mailman id 734803; Mon, 03 Jun 2024 11:07:47 +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 1sE5XW-0007I2-UT for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:07:46 +0000 Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7fbc3c67-2199-11ef-b4bb-af5377834399; Mon, 03 Jun 2024 13:07:44 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 60D4131584; Mon, 3 Jun 2024 07:07:42 -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 59D7B31583; Mon, 3 Jun 2024 07:07:42 -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 13F4931582; Mon, 3 Jun 2024 07:07:39 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 7fbc3c67-2199-11ef-b4bb-af5377834399 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=x+pyBWLmT+o8FD/HTumT5AioH ODe7ZP15Is2zs12tZU=; b=Qst45r6mx/Nd4gbGNoc2Igg+WPHgY8G64WZPpHSHi h7ELaEBkZJiD1Wia1jaLYWYH56tfpnYy+2d6XAce68R5CX5d8mFFuCoCYpsCJhY8 m1rWr4IpzxWQk6/BiyhuiQJXncJhojp1kOItgDO+nlq0rwFgyczD5wMprbGtSuTK Hc= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Xenia Ragiadakou , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , George Dunlap , Stefano Stabellini , Xenia Ragiadakou , Sergiy Kibrik Subject: [XEN PATCH v3 01/16] x86: introduce AMD-V and Intel VT-x Kconfig options Date: Mon, 3 Jun 2024 14:07:35 +0300 Message-Id: <72439ab1749b4bdca3c74a7d2af0254d23626797.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 7D7F25B4-2199-11EF-AD40-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717412886449100001 Content-Type: text/plain; charset="utf-8" From: Xenia Ragiadakou Introduce two new Kconfig options, SVM and VMX, to allow code specific to each virtualization technology to be separated and, when not required, stripped. CONFIG_SVM will be used to enable virtual machine extensions on platforms t= hat implement the AMD Virtualization Technology (AMD-V). CONFIG_VMX will be used to enable virtual machine extensions on platforms t= hat implement the Intel Virtualization Technology (Intel VT-x). Both features depend on HVM support. Since, at this point, disabling any of them would cause Xen to not compile, the options are enabled by default if HVM and are not selectable by the use= r. No functional change intended. Signed-off-by: Xenia Ragiadakou Signed-off-by: Sergiy Kibrik Acked-by: Jan Beulich --- changes in v3: - tag added changes in v2: - simplify kconfig expression to def_bool HVM - keep file list in Makefile in alphabetical order changes in v1: - change kconfig option name AMD_SVM/INTEL_VMX -> SVM/VMX --- xen/arch/x86/Kconfig | 6 ++++++ xen/arch/x86/hvm/Makefile | 4 ++-- xen/arch/x86/mm/Makefile | 3 ++- xen/arch/x86/mm/hap/Makefile | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 7e03e4bc55..8c9f8431f0 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -122,6 +122,12 @@ config HVM =20 If unsure, say Y. =20 +config SVM + def_bool HVM + +config VMX + def_bool HVM + config XEN_SHSTK bool "Supervisor Shadow Stacks" depends on HAS_AS_CET_SS diff --git a/xen/arch/x86/hvm/Makefile b/xen/arch/x86/hvm/Makefile index 3464191544..8434badc64 100644 --- a/xen/arch/x86/hvm/Makefile +++ b/xen/arch/x86/hvm/Makefile @@ -1,5 +1,5 @@ -obj-y +=3D svm/ -obj-y +=3D vmx/ +obj-$(CONFIG_SVM) +=3D svm/ +obj-$(CONFIG_VMX) +=3D vmx/ obj-y +=3D viridian/ =20 obj-y +=3D asid.o diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile index 0803ac9297..0128ca7ab6 100644 --- a/xen/arch/x86/mm/Makefile +++ b/xen/arch/x86/mm/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_MEM_SHARING) +=3D mem_sharing.o obj-$(CONFIG_HVM) +=3D nested.o obj-$(CONFIG_HVM) +=3D p2m.o obj-y +=3D p2m-basic.o -obj-$(CONFIG_HVM) +=3D p2m-ept.o p2m-pod.o p2m-pt.o +obj-$(CONFIG_VMX) +=3D p2m-ept.o +obj-$(CONFIG_HVM) +=3D p2m-pod.o p2m-pt.o obj-y +=3D paging.o obj-y +=3D physmap.o diff --git a/xen/arch/x86/mm/hap/Makefile b/xen/arch/x86/mm/hap/Makefile index 8ef54b1faa..98c8a87819 100644 --- a/xen/arch/x86/mm/hap/Makefile +++ b/xen/arch/x86/mm/hap/Makefile @@ -3,4 +3,4 @@ obj-y +=3D guest_walk_2.o obj-y +=3D guest_walk_3.o obj-y +=3D guest_walk_4.o obj-y +=3D nested_hap.o -obj-y +=3D nested_ept.o +obj-$(CONFIG_VMX) +=3D nested_ept.o --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717413010; cv=none; d=zohomail.com; s=zohoarc; b=f9tjNErjCCuLjCTwQacvA3RkEyn90xxLD1DTwYlOPNBt0YBSvkfVJpWFCbqZ+HodzCdjk84ts00sfVuJafKHegNYnULcVFk1iwlTCUndDIqORWs6kEHzTRmuRFimBcLVMAhXCVraGwDbUs2ulb+6uQKfnzTeZVf3KQ+dncLZqF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717413010; h=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=BwdAjk6UudzZITXdEA77TGobuSzBej1dZsYT+bBikgQ=; b=jACCbu10ijCun6RgqPfG7CM31uJRWtl0ff134c8FgtGxlZ4P8s7g2w/S1jOWLLs9o9gkD6jbJK5a5Jg/6B3tIrN/YbiR6jpOsGTn1ZtqL7PJhngAFLJv7Q/BV5AYzaNrjvIuh3eBhgHWWhjAYoNFlrXTJFqh6LeN9G+eHqQcSBU= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717413010317885.3947110400513; Mon, 3 Jun 2024 04:10:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734808.1140887 (Exim 4.92) (envelope-from ) id 1sE5ZZ-00089C-Rg; Mon, 03 Jun 2024 11:09:53 +0000 Received: by outflank-mailman (output) from mailman id 734808.1140887; Mon, 03 Jun 2024 11:09:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5ZZ-000895-Oo; Mon, 03 Jun 2024 11:09:53 +0000 Received: by outflank-mailman (input) for mailman id 734808; Mon, 03 Jun 2024 11:09:52 +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 1sE5ZY-00086P-7s for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:09:52 +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 cb617c31-2199-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:09:51 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 60E6031593; Mon, 3 Jun 2024 07:09:49 -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 5887B31592; Mon, 3 Jun 2024 07:09:49 -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 0E8263158F; Mon, 3 Jun 2024 07:09:45 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: cb617c31-2199-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=sPIOjqAVFxujq+o241jW7icrs Sxi6WsPSyOt9m/OrS8=; b=anWlnWgXFC7YX/SHvzJnwB3j/H5i0sj4x3YM+JkVW HZnxk481sqaqdMsHrpwqwsVAc2D99tPEBiDt/zQF818QJlq0ZHCCLoKpHQM7Il9L bS2ukjBwHGUzPi3/UGF+uUs+Rp/U2tbH9PlxW86Qf16Zep9FST9CtWkvjUzXeF90 qs= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Jan Beulich , Stefano Stabellini , Xenia Ragiadakou , Tamas K Lengyel Subject: [XEN PATCH v3 02/16] x86/altp2m: check if altp2m active when giving away p2midx Date: Mon, 3 Jun 2024 14:09:42 +0300 Message-Id: <9306d31184b8e714c3a10ccc6a2b2c6a80777ddb.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: C92EAAC0-2199-11EF-B728-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717413011583100001 Content-Type: text/plain; charset="utf-8" Explicitly check whether altp2m is on for domain when getting altp2m index. The puspose of that is later to be able to disable altp2m support and exclude its code from the build completely, when not supported by target platform (as of now it's implemented for Intel EPT only). Signed-off-by: Sergiy Kibrik CC: Tamas K Lengyel CC: Jan Beulich --- changes in v3: - move altp2m_active() check inside altp2m_vcpu_idx() - drop changes to monitor.c - changed patch description changes in v2: - patch description changed, removed VMX mentioning - guard by altp2m_active() instead of hvm_altp2m_supported() --- xen/arch/x86/include/asm/altp2m.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/include/asm/altp2m.h b/xen/arch/x86/include/asm/a= ltp2m.h index e5e59cbd68..2d36c5aa9b 100644 --- a/xen/arch/x86/include/asm/altp2m.h +++ b/xen/arch/x86/include/asm/altp2m.h @@ -26,10 +26,6 @@ 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) -{ - return vcpu_altp2m(v).p2midx; -} #else =20 static inline bool altp2m_active(const struct domain *d) @@ -38,9 +34,13 @@ static inline bool altp2m_active(const struct domain *d) } =20 /* Only declaration is needed. DCE will optimise it out when linking. */ -uint16_t altp2m_vcpu_idx(const struct vcpu *v); void altp2m_vcpu_disable_ve(struct vcpu *v); =20 #endif =20 +static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v) +{ + return altp2m_active(v->domain) ? vcpu_altp2m(v).p2midx : 0; +} + #endif /* __ASM_X86_ALTP2M_H */ --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717413137; cv=none; d=zohomail.com; s=zohoarc; b=YqT+Uvp785mowvLmicLCVIggZJSa8RIWsZh8SlSrDbSnEWIMVzr48g1cCA+iSMOeeFKOqYaqWDwQ7yaAtBPEbSjb3LVjBZ5075b8Y3pfOxY/Lv9B+Glw21LqI1u0tmn519pFdbacAlOgAOvWIsc91VJGWYhqcMlxsatxqI5ADkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717413137; h=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=y581y/pRhKSPoekc36TJPcEIMmTR+l6gSCD/9qZKM20=; b=eDpiIzFFmFb0Xt5JEBNZAcT/ZDZVNG6SdVUxX+YQWiRt2Noff66rFMmBG6UJpW13NvDP45csR9QtyrmzeK0D+8vfGnCFRhzAL7OH848Ve3VM/6pOMJio2DFS6SxPH67hMNs7DyGfBcUYtE5jXvoB5isJq9K7V4pnmnT/NrhUyz4= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717413137734902.1274075971486; Mon, 3 Jun 2024 04:12:17 -0700 (PDT) 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 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-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: 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=20Pau=20Monn=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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717413138057100001 Content-Type: text/plain; charset="utf-8" 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 platf= orm. 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; } =20 - rc =3D p2m_init_altp2m(d); + rc =3D 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); } =20 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); =20 - if ( entry_written && p2m_is_hostp2m(p2m) ) + if ( hvm_altp2m_supported() && entry_written && p2m_is_hostp2m(p2m) ) { ret =3D p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt= , p2ma); if ( !rc ) --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717413263; cv=none; d=zohomail.com; s=zohoarc; b=nUH1wVQce322jjx3RLs/WuZF5sik4k/vcVMxuyfRv8TVYp4OW4sISQ38Hk3Kg5BgHdYmfYGxKX7xCVmHPO8WWBNnhInoLwdYzCh5qyqc1O2u1UJKGgrKanF4uQYhJjBMeA+mWXUArDrq+O/da+4C3oSl/bk1fNh/Mo60iUrhHUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717413263; h=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=JX79ct6698NURKwsFYY0PgJLOHYfWWQNfXKnJhVMuqs=; b=gVunT4mYiAKIV4ST32ZA+r/RRJ9zfhpwzrpiVG/72QbcmTJ9xcB/AOHTjkPTwh1RhT/Td2g//+X8po1fHTBI5kYYkTTSjaw1635cXG/6wLPUzclrIuD5iTtmT1rTDooHmVJuXZy47aOPI7UI7IcapvxVZp/JXK6fqSVJyFaP0Ko= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717413263187959.0995153245057; Mon, 3 Jun 2024 04:14:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734821.1140906 (Exim 4.92) (envelope-from ) id 1sE5df-0001nc-JL; Mon, 03 Jun 2024 11:14:07 +0000 Received: by outflank-mailman (output) from mailman id 734821.1140906; Mon, 03 Jun 2024 11:14:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5df-0001nT-GL; Mon, 03 Jun 2024 11:14:07 +0000 Received: by outflank-mailman (input) for mailman id 734821; Mon, 03 Jun 2024 11:14:06 +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 1sE5de-0001nH-1h for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:14:06 +0000 Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6235b457-219a-11ef-b4bb-af5377834399; Mon, 03 Jun 2024 13:14:03 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 49F4F31605; Mon, 3 Jun 2024 07:14:02 -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 42AD331604; Mon, 3 Jun 2024 07:14:02 -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 485B631602; Mon, 3 Jun 2024 07:13:59 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 6235b457-219a-11ef-b4bb-af5377834399 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=Z5+rlrFJma8dHA+2EwttZvn1p HBH3Y8OD11pFDMz7uM=; b=ZwfXE+GKfiW/cqvlAy9rG4L2Sp7zddb9G/HLsxVgH MQU1KWc2I54tdUx8TPwdw52cLIsnByBmEmpRvecl+kD0/w9fYvZVCQieN0ADNqV/ AYsEoDXmGDzptKxY74OYX3SEkuCRePDu1svT45awUhdTsubIoBjIMBJ9AvpOcc5T yY= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , George Dunlap , Jan Beulich , Stefano Stabellini , Xenia Ragiadakou , Tamas K Lengyel Subject: [XEN PATCH v3 04/16] x86: introduce CONFIG_ALTP2M Kconfig option Date: Mon, 3 Jun 2024 14:13:55 +0300 Message-Id: <035f63f2b92b963f2585064fa21e09e73157f9d3.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 601F0EDE-219A-11EF-A03A-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717413264670100001 Content-Type: text/plain; charset="utf-8" Add new option to make altp2m code inclusion optional. Currently altp2m implemented for Intel EPT only, so option is dependant on = VMX. Also the prompt itself depends on EXPERT=3Dy, so that option is available for fine-tuning, if one want to play around with it. Use this option instead of more generic CONFIG_HVM option. That implies the possibility to build hvm code without altp2m support, hence we need to declare altp2m routines for hvm code to compile successful= ly (altp2m_vcpu_initialise(), altp2m_vcpu_destroy(), altp2m_vcpu_enable_ve()) Also guard altp2m routines, so that they can be disabled completely in the build -- when target platform does not actually support altp2m (AMD-V & ARM as of now). Signed-off-by: Sergiy Kibrik CC: Tamas K Lengyel CC: Jan Beulich CC: Stefano Stabellini --- changes in v3: - added help text - use conditional prompt depending on EXPERT=3Dy - corrected & extended patch description - put a blank line before #ifdef CONFIG_ALTP2M - sqashed in a separate patch for guarding altp2m code with CONFIG_ALTP2M = option changes in v2: - use separate CONFIG_ALTP2M option instead of CONFIG_VMX --- xen/arch/x86/Kconfig | 11 +++++++++++ xen/arch/x86/include/asm/altp2m.h | 5 ++++- xen/arch/x86/include/asm/hvm/hvm.h | 2 +- xen/arch/x86/include/asm/p2m.h | 17 ++++++++++++++++- xen/arch/x86/mm/Makefile | 2 +- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 8c9f8431f0..4a35c43dc5 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -358,6 +358,17 @@ config REQUIRE_NX was unavailable. However, if enabled, Xen will no longer boot on any CPU which is lacking NX support. =20 +config ALTP2M + bool "Alternate P2M support" if EXPERT + default y + depends on VMX + help + Alternate-p2m allows a guest to manage multiple p2m guest physical + "memory views" (as opposed to a single p2m). + Useful for memory introspection. + + If unsure, stay with defaults. + endmenu =20 source "common/Kconfig" diff --git a/xen/arch/x86/include/asm/altp2m.h b/xen/arch/x86/include/asm/a= ltp2m.h index 2d36c5aa9b..effbef51eb 100644 --- a/xen/arch/x86/include/asm/altp2m.h +++ b/xen/arch/x86/include/asm/altp2m.h @@ -7,7 +7,7 @@ #ifndef __ASM_X86_ALTP2M_H #define __ASM_X86_ALTP2M_H =20 -#ifdef CONFIG_HVM +#ifdef CONFIG_ALTP2M =20 #include #include /* for struct vcpu, struct domain */ @@ -34,6 +34,9 @@ static inline bool altp2m_active(const struct domain *d) } =20 /* Only declaration is needed. DCE will optimise it out when linking. */ +void altp2m_vcpu_initialise(struct vcpu *v); +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 #endif diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/= hvm/hvm.h index 1c01e22c8e..2ebea1a92c 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -670,7 +670,7 @@ static inline bool hvm_hap_supported(void) /* returns true if hardware supports alternate p2m's */ static inline bool hvm_altp2m_supported(void) { - return hvm_funcs.caps.altp2m; + return IS_ENABLED(CONFIG_ALTP2M) && hvm_funcs.caps.altp2m; } =20 /* Returns true if we have the minimum hardware requirements for nested vi= rt */ diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index c1478ffc36..b247aa4c7d 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -577,10 +577,10 @@ static inline gfn_t mfn_to_gfn(const struct domain *d= , mfn_t mfn) return _gfn(mfn_x(mfn)); } =20 -#ifdef CONFIG_HVM #define AP2MGET_prepopulate true #define AP2MGET_query false =20 +#ifdef CONFIG_ALTP2M /* * Looks up altp2m entry. If the entry is not found it looks up the entry = in * hostp2m. @@ -589,6 +589,15 @@ static inline gfn_t mfn_to_gfn(const struct domain *d,= mfn_t mfn) int altp2m_get_effective_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *= mfn, p2m_type_t *t, p2m_access_t *a, bool prepopulate); +#else +static inline int altp2m_get_effective_entry(struct p2m_domain *ap2m, + gfn_t gfn, mfn_t *mfn, + p2m_type_t *t, p2m_access_t *= a, + bool prepopulate) +{ + ASSERT_UNREACHABLE(); + return -EOPNOTSUPP; +} #endif =20 /* Init the datastructures for later use by the p2m code */ @@ -914,8 +923,14 @@ static inline bool p2m_set_altp2m(struct vcpu *v, unsi= gned int idx) /* Switch alternate p2m for a single vcpu */ bool p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx); =20 +#ifdef CONFIG_ALTP2M /* Check to see if vcpu should be switched to a different p2m. */ void p2m_altp2m_check(struct vcpu *v, uint16_t idx); +#else +static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) +{ +} +#endif =20 /* Flush all the alternate p2m's for a domain */ void p2m_flush_altp2m(struct domain *d); diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile index 0128ca7ab6..d7d57b8190 100644 --- a/xen/arch/x86/mm/Makefile +++ b/xen/arch/x86/mm/Makefile @@ -1,7 +1,7 @@ obj-y +=3D shadow/ obj-$(CONFIG_HVM) +=3D hap/ =20 -obj-$(CONFIG_HVM) +=3D altp2m.o +obj-$(CONFIG_ALTP2M) +=3D altp2m.o obj-$(CONFIG_HVM) +=3D guest_walk_2.o guest_walk_3.o guest_walk_4.o obj-$(CONFIG_SHADOW_PAGING) +=3D guest_walk_4.o obj-$(CONFIG_MEM_ACCESS) +=3D mem_access.o --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717413386; cv=none; d=zohomail.com; s=zohoarc; b=HLIe8JBcq2fAwu2POKm0WoAwv9/uDMn7t0hNlvsuAe6qvp9wox7/nzYS6bygK0liSTl+gA7KQDY1sgQofv+ttOscAtUmJy2w/Sbnj7OdBBU5P+I6i2EC8NotRg43fk1V+rYULqR7dW8DB7aFJ6UAs6Qp6rO/lsVZc9gZHZiZLBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717413386; h=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=HTunC1Nl6qpmCSK1Y6764Ey1jgCCPl/oVwaLXchtBII=; b=TRdTjhsVhnLe+C2s/a1fV4r2InIywMbYOVsA0j1DiRqBmKKG0GQrrcawr6USSBQ7/H3/cBhCqe7c8wFzZ/Y+gwQ2OIqMUoSql238euklAEXRTEtG/e96ta9YXcCchNhoUn4My2rHhtEJ/14gQVTSyKuRpQYDfvtunjE2ViK76fU= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717413386408234.6377749436598; Mon, 3 Jun 2024 04:16:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734828.1140917 (Exim 4.92) (envelope-from ) id 1sE5fg-0002Ub-4g; Mon, 03 Jun 2024 11:16:12 +0000 Received: by outflank-mailman (output) from mailman id 734828.1140917; Mon, 03 Jun 2024 11:16: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 1sE5fg-0002UU-1b; Mon, 03 Jun 2024 11:16:12 +0000 Received: by outflank-mailman (input) for mailman id 734828; Mon, 03 Jun 2024 11:16:11 +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 1sE5ff-0002UO-1e for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:16:11 +0000 Received: from pb-smtp1.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id acc89b00-219a-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:16:09 +0200 (CEST) Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id BC50E31C4E; Mon, 3 Jun 2024 07:16:07 -0400 (EDT) (envelope-from sakib@darkstar.site) Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id AB0ED31C4D; Mon, 3 Jun 2024 07:16:07 -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-smtp1.pobox.com (Postfix) with ESMTPSA id 23C6931C4C; Mon, 3 Jun 2024 07:16:05 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: acc89b00-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=qSv2cX6hBGxFZiQm0DYgbFSKi 8pVVU7oKD2KrMQ9HqQ=; b=eCO7kCNamh1bXY4xOx7svsIvAQxFMbf/PIFORQXms vxt3LZ83ia6tX7rNfQciujDMhLwchyZYDPqZ7UDegZ5u5adkTvYwDDMACqD1BT4f fR87uRkkpc6SOKO8guuBeCMYYo9/xxxEgCAlxO0ZL822fOgggnGdMFZ9Ktj1cN/K OA= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Jan Beulich , Stefano Stabellini , Xenia Ragiadakou Subject: [XEN PATCH v3 05/16] x86: introduce using_{svm,vmx} macros Date: Mon, 3 Jun 2024 14:16:02 +0300 Message-Id: <9860c4b497038abda71084ea3bce698eab3b277c.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: ABBD3118-219A-11EF-91F9-B84BEB2EC81B-90055647!pb-smtp1.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717413387117100001 Content-Type: text/plain; charset="utf-8" As we now have SVM/VMX config options for enabling/disabling these features completely in the build, we need some build-time checks to ensure that vmx/= svm code can be used and things compile. Macros cpu_has_{svm,vmx} used to be do= ing such checks at runtime, however they do not check if SVM/VMX support is enabled in the build. Also cpu_has_{svm,vmx} can potentially be called from non-{VMX,SVM} build yet running on {VMX,SVM}-enabled CPU, so would correctly indicate that VMX/= SVM is indeed supported by CPU, but code to drive it can't be used. New macros using_{vmx,svm} indicates that both CPU _and_ build provide corresponding technology support, while cpu_has_{vmx,svm} still remains for informational runtime purpose, just as their naming suggests. Signed-off-by: Sergiy Kibrik CC: Jan Beulich --- Here I've followed Jan's suggestion on not touching cpu_has_{vmx,svm} but adding separate macros for solving build problems, and then using these where required. --- changes in v3: - introduce separate macros instead of modifying behaviour of cpu_has_{vmx= ,svm} --- xen/arch/x86/include/asm/hvm/hvm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/= hvm/hvm.h index 2ebea1a92c..778b93df5c 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -26,6 +26,9 @@ extern bool opt_hvm_fep; #define opt_hvm_fep 0 #endif =20 +#define using_vmx ( IS_ENABLED(CONFIG_VMX) && cpu_has_vmx ) +#define using_svm ( IS_ENABLED(CONFIG_SVM) && cpu_has_svm ) + /* Interrupt acknowledgement sources. */ enum hvm_intsrc { hvm_intsrc_none, --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717413518; cv=none; d=zohomail.com; s=zohoarc; b=iV1Mzw4rN2bfqAgMmBNt9XrdlPxw8mXOtV1n9UxuC6ndOKCzHjRpm7cdwuyEXXTUTyXHNFZ9cahRh8Xx52fGrdH6rfZBAT2KCSTKHcnFvNcEFXaRea3DVCDhqpbp7GBe6w8RHCD6LaCTggQIKWXop/SeELoNrqnXpW9WbNTif/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717413518; h=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=0tNe+lHBtMc9hL68KjG4oeqJ+A3o0MLKBUTXL/y0V/g=; b=dOJnHZS8Zka2+HTNAlFv3gYcsOVooI41Z9vJk88VsKRiNp+bOhTfwktyxFt299YK55d63OLeopqXtKR+aHT2Eul0c2Co0Gp06XpvI0A+mXDTfRGOYlcXdoDCMHxRCVj2PuZYpnnBZTXhd160abSW5lmadEeq5Vi6K0fz6hbo2ms= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717413518489156.42121118438286; Mon, 3 Jun 2024 04:18:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734833.1140927 (Exim 4.92) (envelope-from ) id 1sE5hh-00033s-GW; Mon, 03 Jun 2024 11:18:17 +0000 Received: by outflank-mailman (output) from mailman id 734833.1140927; Mon, 03 Jun 2024 11:18: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 1sE5hh-00033l-Co; Mon, 03 Jun 2024 11:18:17 +0000 Received: by outflank-mailman (input) for mailman id 734833; Mon, 03 Jun 2024 11:18:16 +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 1sE5hg-00033f-LU for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:18:16 +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 f846ebcf-219a-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:18:15 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 4FDC8316C9; Mon, 3 Jun 2024 07:18:14 -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 48B78316C8; Mon, 3 Jun 2024 07:18:14 -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 648BD316C7; Mon, 3 Jun 2024 07:18:11 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: f846ebcf-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=EZVyjSsSWDLxpBQraUn0Nt2fs 8KnFVfS9druGNOmUVE=; b=pbSAKgtpWtY8TrguN6fgy7NhvG92n8MDpX6mO1PPp rIXC07gSRsPhMVciOQJ0Ib6qxXVD7jS8SaHHpq5gKJkOWI5aAZM2iNNu6IKgTNom GiJ+DqpP/87ux7lXrKbFsforoA887fpCUpj9/ohY3IshwMzMzW1qE3mlJrQ3Ortu rc= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Xenia Ragiadakou Subject: [XEN PATCH v3 06/16] x86/nestedhvm: switch to using_{svm,vmx} check Date: Mon, 3 Jun 2024 14:18:07 +0300 Message-Id: <63ba1d4e043315693957093688670d36ffa65d28.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: F664D676-219A-11EF-A6B0-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717413520414100001 Content-Type: text/plain; charset="utf-8" Use using_{svm,vmx} instead of cpu_has_{svm,vmx} that not only checks if CPU supports corresponding virtialization technology, but also if it is supported by build configuration. This fixes build when VMX=3Dn or SVM=3Dn, because then start_nested_{svm,vm= x} routine(s) not available. Signed-off-by: Sergiy Kibrik Acked-by: Jan Beulich --- xen/arch/x86/hvm/nestedhvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/nestedhvm.c b/xen/arch/x86/hvm/nestedhvm.c index 451c4da6d4..008dddf801 100644 --- a/xen/arch/x86/hvm/nestedhvm.c +++ b/xen/arch/x86/hvm/nestedhvm.c @@ -155,9 +155,9 @@ static int __init cf_check nestedhvm_setup(void) * done, so that if (for example) HAP is disabled, nested virt is * disabled as well. */ - if ( cpu_has_vmx ) + if ( using_vmx ) start_nested_vmx(&hvm_funcs); - else if ( cpu_has_svm ) + else if ( using_svm ) start_nested_svm(&hvm_funcs); =20 return 0; --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717413638; cv=none; d=zohomail.com; s=zohoarc; b=MVQdQbmhYxzkhv7eU/Q8eVIpJTmbtuUlqChGDaRpk9rKp2z3dgiRWr1t0/XBjICIgJR39ps0e4MJJIp5gciw5Km4ZeVct1onvxFgRFucInbeDD/bchi8s6qvfW5tjIj8IFvHpvJwc0xc5eHOwu2xWn2jikDJ4aYi7XHE82lzMJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717413638; h=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=uWJxCz7QKvPps+OdF0ZKp/4lpPj2c5H8JnVrBuGD1gg=; b=NX8JL3yQDvT12f9nfITTQuHmKpokfgyYS+rnIQVC6NKrapEvNngjGqEMg1D/Gl1Jc9TMiyLtmJVCAv3M6tZGWUiBtfmVQY2JzZw1bOdlsPtGTV445qnkLGzEGVy4aJQhezL1WZs2rVNUqd7CZX3TbT5h/uOBdUXdZL8jucqx+uk= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717413638701786.7680547653456; Mon, 3 Jun 2024 04:20:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734837.1140936 (Exim 4.92) (envelope-from ) id 1sE5jk-0004p3-QZ; Mon, 03 Jun 2024 11:20:24 +0000 Received: by outflank-mailman (output) from mailman id 734837.1140936; Mon, 03 Jun 2024 11:20:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5jk-0004ow-O0; Mon, 03 Jun 2024 11:20:24 +0000 Received: by outflank-mailman (input) for mailman id 734837; Mon, 03 Jun 2024 11:20:23 +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 1sE5jj-0004on-Lq for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:20:23 +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 43d6d3b1-219b-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:20:22 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 3430E3179A; Mon, 3 Jun 2024 07:20:21 -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 2CF4B31799; Mon, 3 Jun 2024 07:20:21 -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 8A66531798; Mon, 3 Jun 2024 07:20:17 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 43d6d3b1-219b-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=n/Gri7cpn2cravDMKsNg30rBQ 5Jg6W+aMAIEGe32Evo=; b=dCF9a04QKrLuNFjVNwZyYfAhQz0S4I/KbajsoeJh3 dRsxghoqoirdKVKmb3iHcUMk/laThMhELQBToZFd3PAlcQCA5LDC49GDx++MbNXr 5rxZmYK/OV+VCAlaRiPh61rwmid4GTfoLoPZ+5SQbtA8xjkCvvcC4NuXzQPQCDQM 5c= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Xenia Ragiadakou , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Xenia Ragiadakou , Sergiy Kibrik Subject: [XEN PATCH v3 07/16] x86/hvm: guard AMD-V and Intel VT-x hvm_function_table initializers Date: Mon, 3 Jun 2024 14:20:14 +0300 Message-Id: <25d4ade03f22ae4eb260af3eae5f48528f2e3ca8.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 4196CF28-219B-11EF-BE08-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717413640888100003 Content-Type: text/plain; charset="utf-8" From: Xenia Ragiadakou Since start_svm() is AMD-V specific while start_vmx() is Intel VT-x specifi= c, any of them can potentially be excluded from build completely with CONFIG_S= VM or CONFIG_VMX options respectively, hence we have to explicitly check if they're available and use specific macros using_{svm,vmx} for that. Signed-off-by: Xenia Ragiadakou Signed-off-by: Sergiy Kibrik Acked-by: Jan Beulich --- changes in v3: - use using_{svm,vmx} macro instead of IS_ENABLED(CONFIG_{SVM,VMX}) - updated description --- xen/arch/x86/hvm/hvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 8334ab1711..7b8679bcd8 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -155,9 +155,9 @@ static int __init cf_check hvm_enable(void) { const struct hvm_function_table *fns =3D NULL; =20 - if ( cpu_has_vmx ) + if ( using_vmx ) fns =3D start_vmx(); - else if ( cpu_has_svm ) + else if ( using_svm ) fns =3D start_svm(); =20 if ( fns =3D=3D NULL ) --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717413764; cv=none; d=zohomail.com; s=zohoarc; b=Qc6BF08dHik4+ROSFGc9UQT48XBfThR+msSRZyKqWjEEp0Ij4VOD9O6H//N38ZO6b7XwOdOMD5P3uvTxeH4MQDBcSMiq+OM4wNsAy9wFnqkEapJTKP+pEfQsrlRQYBkeWRTNSesOuUMFQC5D7cAsADe1nlx1meqekNgo54Ac5dE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717413764; h=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=nqlZx3QF66hUe9heexFyCATrdTxfw1RtuQtV8JMzUKA=; b=ENRFv+ds4McK+zpcO10NerNprPBXyI89tuYb76f0yzeOuXff8tiK49jMM/Wevn9sPHlxERwrT09cytHK5aLHmr7eROoLCvJICDlvCdhOEldfIJr4B0gjq0RvyjKGREKhAbTkkAHjt6WpPyQ2aPM1t6Q+2AZ8bwqKPhMKghDB6qQ= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717413764954991.2583879256657; Mon, 3 Jun 2024 04:22:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734844.1140946 (Exim 4.92) (envelope-from ) id 1sE5ln-0005dl-5h; Mon, 03 Jun 2024 11:22:31 +0000 Received: by outflank-mailman (output) from mailman id 734844.1140946; Mon, 03 Jun 2024 11:22:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5ln-0005de-3A; Mon, 03 Jun 2024 11:22:31 +0000 Received: by outflank-mailman (input) for mailman id 734844; Mon, 03 Jun 2024 11:22:29 +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 1sE5ll-0005dC-8v for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:22:29 +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 8ef92e04-219b-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:22:28 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 56746317B7; Mon, 3 Jun 2024 07:22:27 -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 4EE87317B6; Mon, 3 Jun 2024 07:22:27 -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 20D17317B5; Mon, 3 Jun 2024 07:22:23 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 8ef92e04-219b-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=zTRJcrxkkTEClYsuRZF33f4dO 2xkoYPQYVqoFLYitDA=; b=OhEv95fhpMwMEbss3+HIzhjyAfx9PiUxSJglyEpM+ 6D5t5J+swdquc1xTU6Y00z23wh0hxZpAEa87x5eZNVIOtAtzww0XJjXZyW+4tZaI 6sRSdOgdRU9GwNM7tB9XIU+m29ZAIbtJLp1KqcTuvg3On2s4U381gi+xQZhXyqo+ FE= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Xenia Ragiadakou , Jan Beulich , Andrew Cooper , George Dunlap , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Xenia Ragiadakou , Sergiy Kibrik Subject: [XEN PATCH v3 08/16] x86/p2m: guard EPT functions with using_vmx macro Date: Mon, 3 Jun 2024 14:22:21 +0300 Message-Id: <52c64ffd589f289fda271422fee1e957f94aac6e.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 8D074668-219B-11EF-92C9-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717413765257100001 Content-Type: text/plain; charset="utf-8" From: Xenia Ragiadakou Replace cpu_has_vmx check with using_vmx, so that presence of functions ept_p2m_init() and ept_p2m_uninit() in the build gets checked. Since currently Intel EPT implementation depends on CONFIG_VMX config optio= n, when VMX is off these functions are unavailable. Signed-off-by: Xenia Ragiadakou Signed-off-by: Sergiy Kibrik Acked-by: Jan Beulich --- changes in v3: - using_vmx instead of IS_ENABLED(CONFIG_VMX) - updated description - --- xen/arch/x86/mm/p2m-basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm/p2m-basic.c b/xen/arch/x86/mm/p2m-basic.c index 08007a687c..442284fb40 100644 --- a/xen/arch/x86/mm/p2m-basic.c +++ b/xen/arch/x86/mm/p2m-basic.c @@ -40,7 +40,7 @@ static int p2m_initialise(struct domain *d, struct p2m_do= main *p2m) p2m_pod_init(p2m); p2m_nestedp2m_init(p2m); =20 - if ( hap_enabled(d) && cpu_has_vmx ) + if ( hap_enabled(d) && using_vmx ) ret =3D ept_p2m_init(p2m); else p2m_pt_init(p2m); @@ -72,7 +72,7 @@ struct p2m_domain *p2m_init_one(struct domain *d) void p2m_free_one(struct p2m_domain *p2m) { p2m_free_logdirty(p2m); - if ( hap_enabled(p2m->domain) && cpu_has_vmx ) + if ( hap_enabled(p2m->domain) && using_vmx ) ept_p2m_uninit(p2m); free_cpumask_var(p2m->dirty_cpumask); xfree(p2m); --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717413897; cv=none; d=zohomail.com; s=zohoarc; b=BL9QyNDaRtBHNzaJ+mOBYqzP1QloDuNe9UkXu4R8h2l5eLGKG8UokeD1nHrLYp9dEugGuHtJ9W7fVhdcEqRzKVAmo/6FxtVpPD/2NorWEOAQDilEIbca3IlvJEuGIl5pz6Wg1NRGcNVgQSKm8tAsxOh5CPwJJP7eKgR1LVAc+wg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717413897; h=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=izyz3K/vBDmr4NbEinwIPDgARZ6CBfpp8RkWjgbT1Ro=; b=Y6qWQ08bg6InZmOLRx1c13vvdZNJ5C59H5TjIpBGJ9G9DDrSkCtgfp7Xf+i7MO+qRvTk4YASJpFH/3mnQccFMKFLvRy5HInM4+jLkPwdyoaRCXRIzpYnmCxqyJGYloM7PSLuGOf44lkg9AW9nankaobVJ7YaNOaR2k1OZYN4QzE= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717413897642856.5304115712399; Mon, 3 Jun 2024 04:24:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734851.1140958 (Exim 4.92) (envelope-from ) id 1sE5np-0006BJ-IE; Mon, 03 Jun 2024 11:24:37 +0000 Received: by outflank-mailman (output) from mailman id 734851.1140958; Mon, 03 Jun 2024 11:24:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5np-0006BC-Dy; Mon, 03 Jun 2024 11:24:37 +0000 Received: by outflank-mailman (input) for mailman id 734851; Mon, 03 Jun 2024 11:24:36 +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 1sE5nn-0006B5-VS for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:24:36 +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 da47167b-219b-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:24:34 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 4FC05317C7; Mon, 3 Jun 2024 07:24:33 -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 48509317C6; Mon, 3 Jun 2024 07:24:33 -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 60861317C5; Mon, 3 Jun 2024 07:24:30 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: da47167b-219b-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=sEkjfdgPA5uPcRwW5X9CnC8Lf bf4U4pmRrO5A9YryUE=; b=LhQL90P2fpJ9a4IStB+H/oyPE2fx62KY9i5DwDiMg Z+W52+FFuMDE+/mmn/HYaCFbzwuwdinLyF1On10RA/n8ShUR2ePaVl5pWjQYXVKB +gspc13lb/uy8RWM0LSBNNVLKDRjm/BXsUnK0DLuXxb8ikWHMYl3Ynj+0jradqkX Fo= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Xenia Ragiadakou , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Xenia Ragiadakou , Sergiy Kibrik Subject: [XEN PATCH v3 09/16] x86/traps: guard vmx specific functions with usinc_vmx macro Date: Mon, 3 Jun 2024 14:24:27 +0300 Message-Id: <63045d707485c818af5eafa45752e60405ecf887.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: D84958B4-219B-11EF-B94D-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717413899835100001 Content-Type: text/plain; charset="utf-8" From: Xenia Ragiadakou Replace cpu_has_vmx check with using_vmx, so that not only VMX support in C= PU gets checked, but also presence of functions vmx_vmcs_enter() & vmx_vmcs_ex= it() in the build checked as well. Also since CONFIG_VMX is checked in using_vmx and it depends on CONFIG_HVM, we can drop #ifdef CONFIG_HVM lines around using_vmx. Signed-off-by: Xenia Ragiadakou Signed-off-by: Sergiy Kibrik Acked-by: Jan Beulich --- changes in v3: - using_vmx instead of IS_ENABLED(CONFIG_VMX) - updated description --- xen/arch/x86/traps.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 9906e874d5..a81f3cf57c 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -676,7 +676,6 @@ void vcpu_show_execution_state(struct vcpu *v) =20 vcpu_pause(v); /* acceptably dangerous */ =20 -#ifdef CONFIG_HVM /* * For VMX special care is needed: Reading some of the register state = will * require VMCS accesses. Engaging foreign VMCSes involves acquiring o= f a @@ -684,12 +683,11 @@ void vcpu_show_execution_state(struct vcpu *v) * region. Despite this being a layering violation, engage the VMCS ri= ght * here. This then also avoids doing so several times in close success= ion. */ - if ( cpu_has_vmx && is_hvm_vcpu(v) ) + if ( using_vmx && is_hvm_vcpu(v) ) { ASSERT(!in_irq()); vmx_vmcs_enter(v); } -#endif =20 /* Prevent interleaving of output. */ flags =3D console_lock_recursive_irqsave(); @@ -714,10 +712,8 @@ void vcpu_show_execution_state(struct vcpu *v) console_unlock_recursive_irqrestore(flags); } =20 -#ifdef CONFIG_HVM - if ( cpu_has_vmx && is_hvm_vcpu(v) ) + if ( using_vmx && is_hvm_vcpu(v) ) vmx_vmcs_exit(v); -#endif =20 vcpu_unpause(v); } --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717414017; cv=none; d=zohomail.com; s=zohoarc; b=FWz0d8h5Qv0Y7AQ3D/IH2PGuCFO9+DIbMvah2GlciWGiDi+Z2VKoisVcWYqEcFZBiOe/InyJFY7Bk83Ppt4L1aqs5t4/2o5QTga3ZEQcRT6RxLpOg1MEvXwQkMGKDzRcBMK6aU2Dj96cZWvPOpBiG+4QAmf7xxhmZgrDZcvDJYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717414017; h=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=Q3WjLR/AoLTr1QXZERrTJ8jEsDEPlfX6vCyXXlmkY5k=; b=hc7DiU4HcKWBh8NI90z+9hV4c4pYaUKcHVz18GKyWlC21I4JxJTkk8l3djNifztIllmvCaN//H9Ml9t2UXIFD8Smqw19/bp5JqwBgEkC6rFjpc9PWkWJadK+ja+BVn+lGquKIIVKtx3WtPjSVlD3Qsm++SFFXFX2NGPHTVsADj0= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717414017720498.7814156811919; Mon, 3 Jun 2024 04:26:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734856.1140967 (Exim 4.92) (envelope-from ) id 1sE5po-0006j8-Sx; Mon, 03 Jun 2024 11:26:40 +0000 Received: by outflank-mailman (output) from mailman id 734856.1140967; Mon, 03 Jun 2024 11:26:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5po-0006j1-Q4; Mon, 03 Jun 2024 11:26:40 +0000 Received: by outflank-mailman (input) for mailman id 734856; Mon, 03 Jun 2024 11:26:40 +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 1sE5po-0006it-Ay for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:26:40 +0000 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 23a22ae2-219c-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:26:38 +0200 (CEST) Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 8F8752A8E7; Mon, 3 Jun 2024 07:26:36 -0400 (EDT) (envelope-from sakib@darkstar.site) Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 8748B2A8E6; Mon, 3 Jun 2024 07:26:36 -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-smtp2.pobox.com (Postfix) with ESMTPSA id A7C7F2A8E5; Mon, 3 Jun 2024 07:26:35 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 23a22ae2-219c-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=C9i/Ss0viC+/vS6vrwKhCdgvC fQtFhYi+LVOUd2WOmY=; b=F827fVDOG7PTj68DkUpBmH/hc3C5ZKUSls6qCAvlV 5zMwJ35Zcgfn39w5fuxXIteq/W7dscCVEfunGa7ZWDR5GJbMEWNYxVsoeQgVwZYi MsiK/LWrlDAEcJwXnAhBF2byjltBHb8QykidMNzP3NnASUbnqybM9PiUJL7VczeK Rc= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Xenia Ragiadakou , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Xenia Ragiadakou , Sergiy Kibrik Subject: [XEN PATCH v3 10/16] x86/domain: guard svm specific functions with usinc_svm macro Date: Mon, 3 Jun 2024 14:26:33 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 22F79E52-219C-11EF-8278-6488940A682E-90055647!pb-smtp2.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717414018230100001 Content-Type: text/plain; charset="utf-8" From: Xenia Ragiadakou Replace cpu_has_svm check with using_svm, so that not only SVM support in C= PU gets checked, but also presence of functions svm_load_segs() and svm_load_segs_prefetch() in the build checked as well. Since SVM depends on HVM, it can be used alone. Signed-off-by: Xenia Ragiadakou Signed-off-by: Sergiy Kibrik Acked-by: Jan Beulich --- changes in v3: - using_svm instead of IS_ENABLED(CONFIG_SVM) - updated description --- xen/arch/x86/domain.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 536542841e..a2f19f8b46 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1731,11 +1731,9 @@ static void load_segments(struct vcpu *n) if ( !(n->arch.flags & TF_kernel_mode) ) SWAP(gsb, gss); =20 -#ifdef CONFIG_HVM - if ( cpu_has_svm && (uregs->fs | uregs->gs) <=3D 3 ) + if ( using_svm && (uregs->fs | uregs->gs) <=3D 3 ) fs_gs_done =3D svm_load_segs(n->arch.pv.ldt_ents, LDT_VIRT_STA= RT(n), n->arch.pv.fs_base, gsb, gss); -#endif } =20 if ( !fs_gs_done ) @@ -2048,9 +2046,9 @@ static void __context_switch(void) =20 write_ptbase(n); =20 -#if defined(CONFIG_PV) && defined(CONFIG_HVM) +#if defined(CONFIG_PV) /* Prefetch the VMCB if we expect to use it later in the context switc= h */ - if ( cpu_has_svm && is_pv_64bit_domain(nd) && !is_idle_domain(nd) ) + if ( using_svm && is_pv_64bit_domain(nd) && !is_idle_domain(nd) ) svm_load_segs_prefetch(); #endif =20 --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717414144; cv=none; d=zohomail.com; s=zohoarc; b=aujG2adttJuYt+MDoKNoCNoOyn5/sDentydsbT2wZ0isYqNy0ehhFjLW5LkfRow0juN1miaXck4LTJITElonsjlK+udrmNeNRD4O6bas/QVmeHBTWOHIqPDuXGElTeOzhg1nTZ3Qo73SvpAkDHjg0zYkTIC90VdH4RGB5QRAn0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717414144; h=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=g4RtRHwCi8IHbN09vZhz1qoEEPr3F/UHZhiDTbdUN9c=; b=hMXmCNw+Tb7mW2Xa4AfNG/4ATAHAiKuMUocCgq0LTKbmiLj0MgPOvvmUmlSoGbUDNO1uRj6TnxkLh6wMXeYf/X77fbrzt/z+YHvUYgrh+8ksTypn9kGE9hXRnSJoJc264uZnhWYBb5UVKilg3gyPeVseXWMUyfh2cRNtWnUTbXg= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717414144216154.4933853848554; Mon, 3 Jun 2024 04:29:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734862.1140976 (Exim 4.92) (envelope-from ) id 1sE5rq-0007Hu-7j; Mon, 03 Jun 2024 11:28:46 +0000 Received: by outflank-mailman (output) from mailman id 734862.1140976; Mon, 03 Jun 2024 11:28:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5rq-0007Hn-4b; Mon, 03 Jun 2024 11:28:46 +0000 Received: by outflank-mailman (input) for mailman id 734862; Mon, 03 Jun 2024 11:28:45 +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 1sE5rp-0007Hh-F2 for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:28:45 +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 6f0f3d40-219c-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:28:44 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 305C4317E8; Mon, 3 Jun 2024 07:28:43 -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 29BF7317E7; Mon, 3 Jun 2024 07:28:43 -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 0BB53317E6; Mon, 3 Jun 2024 07:28:39 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 6f0f3d40-219c-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=/ajn3Y23Ptep8PMnKlNl2X5Wf quTjK0FGfT5lFyKeSU=; b=hPCH2kf9dP1RWVFD/0rd/7nEKY6u6LPWdt1rwCXQL mnHW4Xy7S1YSlJXBpQENZBrkHb6btgLOBg5F4GNIirccVERA9UcSZUq0XjRUvdQA WbHb9IxW+rwIY95fN4I5rFAjlAUbmZH7zBnLGa1/gZqQCC+HoPHoZojpNHcrl5QX XE= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Xenia Ragiadakou , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Xenia Ragiadakou , Sergiy Kibrik Subject: [XEN PATCH v3 11/16] x86/oprofile: guard svm specific symbols with CONFIG_SVM Date: Mon, 3 Jun 2024 14:28:36 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 6D175BF8-219C-11EF-9E81-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717414144780100001 Content-Type: text/plain; charset="utf-8" From: Xenia Ragiadakou The symbol svm_stgi_label is AMD-V specific so guard its usage in common co= de with CONFIG_SVM. Since SVM depends on HVM, it can be used alone. Also, use #ifdef instead of #if. No functional change intended. Signed-off-by: Xenia Ragiadakou Signed-off-by: Sergiy Kibrik Acked-by: Jan Beulich --- xen/arch/x86/oprofile/op_model_athlon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/oprofile/op_model_athlon.c b/xen/arch/x86/oprofil= e/op_model_athlon.c index 69fd3fcc86..a9c7b87d67 100644 --- a/xen/arch/x86/oprofile/op_model_athlon.c +++ b/xen/arch/x86/oprofile/op_model_athlon.c @@ -320,7 +320,7 @@ static int cf_check athlon_check_ctrs( struct vcpu *v =3D current; unsigned int const nr_ctrs =3D model->num_counters; =20 -#if CONFIG_HVM +#ifdef CONFIG_SVM struct cpu_user_regs *guest_regs =3D guest_cpu_user_regs(); =20 if (!guest_mode(regs) && --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717414278; cv=none; d=zohomail.com; s=zohoarc; b=ONxDT9FFbTvnonTq6kj4zwVm8N9qgb4OwnkU66KA5HTAPqhVkFT320+tj7tFe/IrNkju1CWv8XQ6plC4qckPSi5JNp/RICj+NfEhNNe7IeIXb1OAISDiTCXsGeO4WsGwBEnHKVWhfPGhlNghIvsT7Cqs4NG6SqhamifylpuznAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717414278; h=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=Bsg1wtPxHFikQGK5KfrefbY46FQ7quTizTTYUY0fnUU=; b=VDjmt8JvvpE/8kendbLL9jq+fYclExYYyETqLQIGW2NmVaG8b01CONbY7JRyaxKfz4WH/VHJBm0RYhWWnNhf+PSQLHA25OFL6zpeNf9Lg8DapkrKHzqcwXANoWrJviw6S62yg0B4mv3w2+uZQoy2AoWNs+ev2b2bD9yxuMQrKsQ= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17174142781591008.7796608045161; Mon, 3 Jun 2024 04:31:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734869.1140987 (Exim 4.92) (envelope-from ) id 1sE5tv-0000rd-N0; Mon, 03 Jun 2024 11:30:55 +0000 Received: by outflank-mailman (output) from mailman id 734869.1140987; Mon, 03 Jun 2024 11:30:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5tv-0000rW-KM; Mon, 03 Jun 2024 11:30:55 +0000 Received: by outflank-mailman (input) for mailman id 734869; Mon, 03 Jun 2024 11:30:54 +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 1sE5tu-0000qE-1E for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:30:54 +0000 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bac16c16-219c-11ef-b4bb-af5377834399; Mon, 03 Jun 2024 13:30:51 +0200 (CEST) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id BBBF3273FA; Mon, 3 Jun 2024 07:30:49 -0400 (EDT) (envelope-from sakib@darkstar.site) Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id B3434273F9; Mon, 3 Jun 2024 07:30:49 -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-smtp20.pobox.com (Postfix) with ESMTPSA id C8FBC273F8; Mon, 3 Jun 2024 07:30:46 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: bac16c16-219c-11ef-b4bb-af5377834399 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=tFMcVJrjymE8LFOeCd5ZgK9a6 R2CYRHptQF3Am22SyM=; b=DVOuHKfuf0jbFTvrk+Z2anRLLaObxi+C5W7V+h8gv zNbmqz7gugEO8GIumxGLcfqVDrzkisKVsSppqm4R1EY7O3k8D0sA1jNXvvXbKyU+ h2vNbKO7t+PyeEcOuldhUpDh/dr675JR9/E7Z6Z7lj7NC/SnsddtuOZmrfL/Keq8 KA= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Paul Durrant , Jan Beulich , Stefano Stabellini , Xenia Ragiadakou , Andrew Cooper Subject: [XEN PATCH v3 12/16] x86/vmx: guard access to cpu_has_vmx_* in common code Date: Mon, 3 Jun 2024 14:30:43 +0300 Message-Id: <1645c0d4a5aae7b53cfb166ac10235e12ae4dbb1.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: B8A7CE9A-219C-11EF-A069-ACC938F0AE34-90055647!pb-smtp20.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717414279758100001 Content-Type: text/plain; charset="utf-8" There're several places in common code, outside of arch/x86/hvm/vmx, where cpu_has_vmx_* get accessed without checking whether VMX supported fir= st. These macros rely on global variables defined in vmx code, so when VMX supp= ort gets disabled accesses to these variables turn into build failures. To overcome these failures, build-time check is done before accessing global variables, so that DCE would remove these variables. Signed-off-by: Sergiy Kibrik CC: Andrew Cooper CC: Jan Beulich --- changes in v3: - using_vmx instead of cpu_has_vmx - clarify description on why this change needed changes in v2: - do not touch SVM code and macros - drop vmx_ctrl_has_feature() - guard cpu_has_vmx_* macros in common code instead changes in v1: - introduced helper routine vmx_ctrl_has_feature() and used it for all cpu_has_vmx_* macros --- xen/arch/x86/hvm/hvm.c | 2 +- xen/arch/x86/hvm/viridian/viridian.c | 4 ++-- xen/arch/x86/include/asm/hvm/vmx/vmcs.h | 12 ++++++------ xen/arch/x86/traps.c | 5 +++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 7b8679bcd8..af45c5ed8c 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -5197,7 +5197,7 @@ int hvm_debug_op(struct vcpu *v, int32_t op) { case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON: case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF: - if ( !cpu_has_monitor_trap_flag ) + if ( !using_vmx || !cpu_has_monitor_trap_flag ) return -EOPNOTSUPP; break; default: diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index 0496c52ed5..59e7e7955a 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -196,7 +196,7 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32= _t leaf, res->a =3D CPUID4A_RELAX_TIMER_INT; if ( viridian_feature_mask(d) & HVMPV_hcall_remote_tlb_flush ) res->a |=3D CPUID4A_HCALL_REMOTE_TLB_FLUSH; - if ( !cpu_has_vmx_apic_reg_virt ) + if ( !using_vmx || !cpu_has_vmx_apic_reg_virt ) res->a |=3D CPUID4A_MSR_BASED_APIC; if ( viridian_feature_mask(d) & HVMPV_hcall_ipi ) res->a |=3D CPUID4A_SYNTHETIC_CLUSTER_IPI; @@ -236,7 +236,7 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32= _t leaf, =20 case 6: /* Detected and in use hardware features. */ - if ( cpu_has_vmx_virtualize_apic_accesses ) + if ( using_vmx && cpu_has_vmx_virtualize_apic_accesses ) res->a |=3D CPUID6A_APIC_OVERLAY; if ( cpu_has_vmx_msr_bitmap || (read_efer() & EFER_SVME) ) res->a |=3D CPUID6A_MSR_BITMAPS; diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h b/xen/arch/x86/include= /asm/hvm/vmx/vmcs.h index 58140af691..713088b8d3 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -306,7 +306,7 @@ extern u64 vmx_ept_vpid_cap; #define cpu_has_vmx_vnmi \ (vmx_pin_based_exec_control & PIN_BASED_VIRTUAL_NMIS) #define cpu_has_vmx_msr_bitmap \ - (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_MSR_BITMAP) + (using_vmx && vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_MSR_BITM= AP) #define cpu_has_vmx_secondary_exec_control \ (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) #define cpu_has_vmx_tertiary_exec_control \ @@ -316,7 +316,7 @@ extern u64 vmx_ept_vpid_cap; #define cpu_has_vmx_dt_exiting \ (vmx_secondary_exec_control & SECONDARY_EXEC_DESCRIPTOR_TABLE_EXITING) #define cpu_has_vmx_rdtscp \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_RDTSCP) + (using_vmx && vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_RDTSC= P) #define cpu_has_vmx_vpid \ (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID) #define cpu_has_monitor_trap_flag \ @@ -333,7 +333,7 @@ extern u64 vmx_ept_vpid_cap; #define cpu_has_vmx_ple \ (vmx_secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) #define cpu_has_vmx_invpcid \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_INVPCID) + (using_vmx && vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_INVPC= ID) #define cpu_has_vmx_apic_reg_virt \ (vmx_secondary_exec_control & SECONDARY_EXEC_APIC_REGISTER_VIRT) #define cpu_has_vmx_virtual_intr_delivery \ @@ -347,14 +347,14 @@ extern u64 vmx_ept_vpid_cap; #define cpu_has_vmx_vmfunc \ (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VM_FUNCTIONS) #define cpu_has_vmx_virt_exceptions \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS) + (using_vmx && vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VIRT_= EXCEPTIONS) #define cpu_has_vmx_pml \ (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_PML) #define cpu_has_vmx_mpx \ - ((vmx_vmexit_control & VM_EXIT_CLEAR_BNDCFGS) && \ + (using_vmx && (vmx_vmexit_control & VM_EXIT_CLEAR_BNDCFGS) && \ (vmx_vmentry_control & VM_ENTRY_LOAD_BNDCFGS)) #define cpu_has_vmx_xsaves \ - (vmx_secondary_exec_control & SECONDARY_EXEC_XSAVES) + (using_vmx && vmx_secondary_exec_control & SECONDARY_EXEC_XSAVES) #define cpu_has_vmx_tsc_scaling \ (vmx_secondary_exec_control & SECONDARY_EXEC_TSC_SCALING) #define cpu_has_vmx_bus_lock_detection \ diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index a81f3cf57c..c2f29fc9a4 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1130,7 +1130,7 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, ui= nt32_t leaf, if ( !is_hvm_domain(d) || subleaf !=3D 0 ) break; =20 - if ( cpu_has_vmx_apic_reg_virt ) + if ( using_vmx && cpu_has_vmx_apic_reg_virt ) res->a |=3D XEN_HVM_CPUID_APIC_ACCESS_VIRT; =20 /* @@ -1139,7 +1139,8 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, ui= nt32_t leaf, * and wrmsr in the guest will run without VMEXITs (see * vmx_vlapic_msr_changed()). */ - if ( cpu_has_vmx_virtualize_x2apic_mode && + if ( using_vmx && + cpu_has_vmx_virtualize_x2apic_mode && cpu_has_vmx_apic_reg_virt && cpu_has_vmx_virtual_intr_delivery ) res->a |=3D XEN_HVM_CPUID_X2APIC_VIRT; --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717414397; cv=none; d=zohomail.com; s=zohoarc; b=SwB7G6JXiLUK3AgfYQ3HT09o9tQ/JyIfGokNijp1ZA3fomuexosg9SSX5YztSza1XYd7pcsCMOJZqWR2zGjlq7vkk0Jw4B3W7VoE0Va4zDqyrNtjGfY801nGK7UJZp03HzSVISTDiHIKWJCpoWCE0nT68+R34DuBhDPgwpn62i8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717414397; h=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=6nYuvDbHrOaqkVtwQGUD8Woo9bW0XXOdPiJR9aABHMY=; b=MkL+6qKW8lTwQigFPgUYYbJWeH9d14UonLtf2RjMQP74EwsEiRrTymYeynR22WTFGANcgX6X25NPt7JpY6U8M6CLDmuHTUUvKVCE1z3nBWyucbT+jskCIueyfHVCnD4pPTPP0w8WgCGQRnKUKaianSig2CIDBma6yQHss+1j2A4= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 171741439736572.59508611733281; Mon, 3 Jun 2024 04:33:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734878.1140997 (Exim 4.92) (envelope-from ) id 1sE5vv-0001tz-2M; Mon, 03 Jun 2024 11:32:59 +0000 Received: by outflank-mailman (output) from mailman id 734878.1140997; Mon, 03 Jun 2024 11:32:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5vu-0001ts-VJ; Mon, 03 Jun 2024 11:32:58 +0000 Received: by outflank-mailman (input) for mailman id 734878; Mon, 03 Jun 2024 11:32:57 +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 1sE5vt-0001tR-Je for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:32:57 +0000 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 03e42810-219d-11ef-b4bb-af5377834399; Mon, 03 Jun 2024 13:32:54 +0200 (CEST) Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 9F1E42A952; Mon, 3 Jun 2024 07:32:52 -0400 (EDT) (envelope-from sakib@darkstar.site) Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 954432A951; Mon, 3 Jun 2024 07:32:52 -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-smtp2.pobox.com (Postfix) with ESMTPSA id C5AB22A950; Mon, 3 Jun 2024 07:32:51 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 03e42810-219d-11ef-b4bb-af5377834399 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=qFt1GhHtKwmXz/WKqzqf/F4up h4obWVv/1gPxRugSAk=; b=eb/w/s2vBAl1xjuLGLhjiOsOKxouCwL4tCmyPuNr4 s1tVy5bcyujmGfgxPFTy1dwn0MDaMpN+BwVG4rD+PXRwZB1oJU9AqHZ9qN9CpRq0 sNwmfOpNyAp3UM4gOoNlXy7GX/cm1nhomnFHH+rwaG28E/bf732DDkGHyNDLJz6M bs= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Xenia Ragiadakou Subject: [XEN PATCH v3 13/16] x86/vpmu: guard calls to vmx/svm functions Date: Mon, 3 Jun 2024 14:32:49 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 03271692-219D-11EF-AFD9-6488940A682E-90055647!pb-smtp2.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717414398005100005 Content-Type: text/plain; charset="utf-8" If VMX/SVM disabled in the build, we may still want to have vPMU drivers for PV guests. Yet in such case before using VMX/SVM features and functions we = have to explicitly check if they're available in the build. For this puspose (and also not to complicate conditionals) two helpers introduced -- is_{vmx,svm}_vcpu(v) that check both HVM & VMX/SVM conditions at the same t= ime, and they replace is_hvm_vcpu(v) macro where needed. Signed-off-by: Sergiy Kibrik --- changes in v3: - introduced macro is_{vmx,svm}_vcpu(v) - changed description - reordered patch, do not modify conditionals w/ cpu_has_vmx_msr_bitmap ch= eck --- xen/arch/x86/cpu/vpmu_amd.c | 9 +++++---- xen/arch/x86/cpu/vpmu_intel.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/cpu/vpmu_amd.c b/xen/arch/x86/cpu/vpmu_amd.c index 97e6315bd9..217501ecd3 100644 --- a/xen/arch/x86/cpu/vpmu_amd.c +++ b/xen/arch/x86/cpu/vpmu_amd.c @@ -27,6 +27,7 @@ #define is_pmu_enabled(msr) ((msr) & (1ULL << MSR_F10H_EVNTSEL_EN_SHIFT)) #define set_guest_mode(msr) ((msr) |=3D (1ULL << MSR_F10H_EVNTSEL_GO_SHIFT= )) #define is_overflowed(msr) (!((msr) & (1ULL << (MSR_F10H_COUNTER_LENGTH - = 1)))) +#define is_svm_vcpu(v) (using_svm && is_hvm_vcpu(v)) =20 static unsigned int __read_mostly num_counters; static const u32 __read_mostly *counters; @@ -289,7 +290,7 @@ static int cf_check amd_vpmu_save(struct vcpu *v, bool= to_guest) =20 context_save(v); =20 - if ( !vpmu_is_set(vpmu, VPMU_RUNNING) && is_hvm_vcpu(v) && + if ( !vpmu_is_set(vpmu, VPMU_RUNNING) && is_svm_vcpu(v) && is_msr_bitmap_on(vpmu) ) amd_vpmu_unset_msr_bitmap(v); =20 @@ -363,7 +364,7 @@ static int cf_check amd_vpmu_do_wrmsr(unsigned int msr,= uint64_t msr_content) return 0; vpmu_set(vpmu, VPMU_RUNNING); =20 - if ( is_hvm_vcpu(v) && is_msr_bitmap_on(vpmu) ) + if ( is_svm_vcpu(v) && is_msr_bitmap_on(vpmu) ) amd_vpmu_set_msr_bitmap(v); } =20 @@ -372,7 +373,7 @@ static int cf_check amd_vpmu_do_wrmsr(unsigned int msr,= uint64_t msr_content) (is_pmu_enabled(msr_content) =3D=3D 0) && vpmu_is_set(vpmu, VPMU_R= UNNING) ) { vpmu_reset(vpmu, VPMU_RUNNING); - if ( is_hvm_vcpu(v) && is_msr_bitmap_on(vpmu) ) + if ( is_svm_vcpu(v) && is_msr_bitmap_on(vpmu) ) amd_vpmu_unset_msr_bitmap(v); release_pmu_ownership(PMU_OWNER_HVM); } @@ -415,7 +416,7 @@ static void cf_check amd_vpmu_destroy(struct vcpu *v) { struct vpmu_struct *vpmu =3D vcpu_vpmu(v); =20 - if ( is_hvm_vcpu(v) && is_msr_bitmap_on(vpmu) ) + if ( is_svm_vcpu(v) && is_msr_bitmap_on(vpmu) ) amd_vpmu_unset_msr_bitmap(v); =20 xfree(vpmu->context); diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c index cd414165df..f95a9b058d 100644 --- a/xen/arch/x86/cpu/vpmu_intel.c +++ b/xen/arch/x86/cpu/vpmu_intel.c @@ -54,6 +54,8 @@ #define MSR_PMC_ALIAS_MASK (~(MSR_IA32_PERFCTR0 ^ MSR_IA32_A_PERFCTR= 0)) static bool __read_mostly full_width_write; =20 +#define is_vmx_vcpu(v) ( using_vmx && is_hvm_vcpu(v) ) + /* * MSR_CORE_PERF_FIXED_CTR_CTRL contains the configuration of all fixed * counters. 4 bits for every counter. @@ -269,7 +271,7 @@ static inline void __core2_vpmu_save(struct vcpu *v) if ( !is_hvm_vcpu(v) ) rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, core2_vpmu_cxt->global_status); /* Save MSR to private context to make it fork-friendly */ - else if ( mem_sharing_enabled(v->domain) ) + else if ( is_vmx_vcpu(v) && mem_sharing_enabled(v->domain) ) vmx_read_guest_msr(v, MSR_CORE_PERF_GLOBAL_CTRL, &core2_vpmu_cxt->global_ctrl); } @@ -333,7 +335,7 @@ static inline void __core2_vpmu_load(struct vcpu *v) wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, core2_vpmu_cxt->global_ctrl); } /* Restore MSR from context when used with a fork */ - else if ( mem_sharing_is_fork(v->domain) ) + else if ( is_vmx_vcpu(v) && mem_sharing_is_fork(v->domain) ) vmx_write_guest_msr(v, MSR_CORE_PERF_GLOBAL_CTRL, core2_vpmu_cxt->global_ctrl); } @@ -442,7 +444,7 @@ static int cf_check core2_vpmu_alloc_resource(struct vc= pu *v) if ( !acquire_pmu_ownership(PMU_OWNER_HVM) ) return 0; =20 - if ( is_hvm_vcpu(v) ) + if ( is_vmx_vcpu(v) ) { if ( vmx_add_host_load_msr(v, MSR_CORE_PERF_GLOBAL_CTRL, 0) ) goto out_err; @@ -584,7 +586,7 @@ static int cf_check core2_vpmu_do_wrmsr(unsigned int ms= r, uint64_t msr_content) if ( msr_content & fixed_ctrl_mask ) return -EINVAL; =20 - if ( is_hvm_vcpu(v) ) + if ( is_vmx_vcpu(v) ) vmx_read_guest_msr(v, MSR_CORE_PERF_GLOBAL_CTRL, &core2_vpmu_cxt->global_ctrl); else @@ -653,7 +655,7 @@ static int cf_check core2_vpmu_do_wrmsr(unsigned int ms= r, uint64_t msr_content) if ( blocked ) return -EINVAL; =20 - if ( is_hvm_vcpu(v) ) + if ( is_vmx_vcpu(v) ) vmx_read_guest_msr(v, MSR_CORE_PERF_GLOBAL_CTRL, &core2_vpmu_cxt->global_ctrl); else @@ -672,7 +674,7 @@ static int cf_check core2_vpmu_do_wrmsr(unsigned int ms= r, uint64_t msr_content) wrmsrl(msr, msr_content); else { - if ( is_hvm_vcpu(v) ) + if ( is_vmx_vcpu(v) ) vmx_write_guest_msr(v, MSR_CORE_PERF_GLOBAL_CTRL, msr_content); else wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, msr_content); @@ -706,7 +708,7 @@ static int cf_check core2_vpmu_do_rdmsr(unsigned int ms= r, uint64_t *msr_content) *msr_content =3D core2_vpmu_cxt->global_status; break; case MSR_CORE_PERF_GLOBAL_CTRL: - if ( is_hvm_vcpu(v) ) + if ( is_vmx_vcpu(v) ) vmx_read_guest_msr(v, MSR_CORE_PERF_GLOBAL_CTRL, msr_conte= nt); else rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, *msr_content); --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717414514; cv=none; d=zohomail.com; s=zohoarc; b=WTtoCrdSMQ7vVB11uH7zSU+VkpEzOeqXnCRQgUhmp7enWeGmwgbFNMKRxq8OSCQReV0WZqDTKgjoRUK+0ObhEdTWXNz6+BnAgtP2QozbSgKwm/DFccDdY3Zod903LwKibcC2dC4irDKu1vLVfFIlT30tcVeqYV0b4wqpL3/M+6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717414514; h=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=Q+WQq5fA5RnOcqwlSQ40eXkQFOKKggK6YxbL/XjpEZk=; b=Ao3xxktwtX0mEo4GAVJmsIBk3O7Uy82my/2EuIIvNE57MuZDaDWaQwkkkEJNYfF03oE7SIRdyZF8TOCv/Twa0Hg9DjwSqKnB/WfL/ihad+pIJbSZGdNqMS3XVKLyj4rqI7GfLLER91fafDcaxMdtmDJ4/B1TgAjB3tg0hN2YIPo= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717414514076581.0594153304821; Mon, 3 Jun 2024 04:35:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734883.1141007 (Exim 4.92) (envelope-from ) id 1sE5xr-0002RJ-DN; Mon, 03 Jun 2024 11:34:59 +0000 Received: by outflank-mailman (output) from mailman id 734883.1141007; Mon, 03 Jun 2024 11:34:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5xr-0002RC-9T; Mon, 03 Jun 2024 11:34:59 +0000 Received: by outflank-mailman (input) for mailman id 734883; Mon, 03 Jun 2024 11:34: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 1sE5xq-0002Qn-61 for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:34:58 +0000 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4d5a9d82-219d-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:34:56 +0200 (CEST) Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 412FF2A963; Mon, 3 Jun 2024 07:34:56 -0400 (EDT) (envelope-from sakib@darkstar.site) Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 37BC12A962; Mon, 3 Jun 2024 07:34:56 -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-smtp2.pobox.com (Postfix) with ESMTPSA id 330182A961; Mon, 3 Jun 2024 07:34:54 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 4d5a9d82-219d-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=HkS7PEf8kJUA2RxHxXS98LEBr MEt1ID9/ioAN+1BsYg=; b=QqwbSLPTK4nhdLFUwp4v1x2GmmVp2h+6EoIzXwYYj G1q9DTzCDsn1Aj9XyY1fig+lx566ZbI3r3Xp2NODp6S9yY6s36UK9WJCogtXezyT pccqmwcnn7aDZbvaayqnU7Vb3EY1XawYZ5GHitOi62MyBIsLyixtP6n8cCRqLbYG Zs= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Xenia Ragiadakou Subject: [XEN PATCH v3 14/16] ioreq: make arch_vcpu_ioreq_completion() an optional callback Date: Mon, 3 Jun 2024 14:34:53 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 4CB4C53E-219D-11EF-A092-6488940A682E-90055647!pb-smtp2.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717414514645100001 Content-Type: text/plain; charset="utf-8" For the most cases arch_vcpu_ioreq_completion() routine is just an empty st= ub, except when handling VIO_realmode_completion, which only happens on HVM domains running on VT-x machine. When VT-x is disabled in build configurati= on, both x86 & arm version of routine become empty stubs. To dispose of these useless stubs we can do optional call to arch-specific ioreq completion handler, if it's present, and drop arm and generic x86 han= dlers. Actual handling of VIO_realmore_completion can be done by VMX code then. Signed-off-by: Sergiy Kibrik --- xen/arch/arm/ioreq.c | 6 ------ xen/arch/x86/hvm/ioreq.c | 23 ----------------------- xen/arch/x86/hvm/vmx/vmx.c | 16 ++++++++++++++++ xen/common/ioreq.c | 5 ++++- xen/include/xen/ioreq.h | 2 +- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/xen/arch/arm/ioreq.c b/xen/arch/arm/ioreq.c index 5df755b48b..2e829d2e7f 100644 --- a/xen/arch/arm/ioreq.c +++ b/xen/arch/arm/ioreq.c @@ -135,12 +135,6 @@ bool arch_ioreq_complete_mmio(void) return false; } =20 -bool arch_vcpu_ioreq_completion(enum vio_completion completion) -{ - ASSERT_UNREACHABLE(); - return true; -} - /* * The "legacy" mechanism of mapping magic pages for the IOREQ servers * is x86 specific, so the following hooks don't need to be implemented on= Arm: diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index 4eb7a70182..088650e007 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -29,29 +29,6 @@ bool arch_ioreq_complete_mmio(void) return handle_mmio(); } =20 -bool arch_vcpu_ioreq_completion(enum vio_completion completion) -{ - switch ( completion ) - { - case VIO_realmode_completion: - { - struct hvm_emulate_ctxt ctxt; - - hvm_emulate_init_once(&ctxt, NULL, guest_cpu_user_regs()); - vmx_realmode_emulate_one(&ctxt); - hvm_emulate_writeback(&ctxt); - - break; - } - - default: - ASSERT_UNREACHABLE(); - break; - } - - return true; -} - static gfn_t hvm_alloc_legacy_ioreq_gfn(struct ioreq_server *s) { struct domain *d =3D s->target; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index f16faa6a61..7187d1819c 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -2749,6 +2750,20 @@ static void cf_check vmx_set_reg(struct vcpu *v, uns= igned int reg, uint64_t val) vmx_vmcs_exit(v); } =20 +bool realmode_vcpu_ioreq_completion(enum vio_completion completion) +{ + struct hvm_emulate_ctxt ctxt; + + if ( completion !=3D VIO_realmode_completion ) + ASSERT_UNREACHABLE(); + + hvm_emulate_init_once(&ctxt, NULL, guest_cpu_user_regs()); + vmx_realmode_emulate_one(&ctxt); + hvm_emulate_writeback(&ctxt); + + return true; +} + static struct hvm_function_table __initdata_cf_clobber vmx_function_table = =3D { .name =3D "VMX", .cpu_up_prepare =3D vmx_cpu_up_prepare, @@ -3070,6 +3085,7 @@ const struct hvm_function_table * __init start_vmx(vo= id) lbr_tsx_fixup_check(); ler_to_fixup_check(); =20 + arch_vcpu_ioreq_completion =3D realmode_vcpu_ioreq_completion; return &vmx_function_table; } =20 diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c index 1257a3d972..94fde97ece 100644 --- a/xen/common/ioreq.c +++ b/xen/common/ioreq.c @@ -33,6 +33,8 @@ #include #include =20 +bool (*arch_vcpu_ioreq_completion)(enum vio_completion completion) =3D NUL= L; + void ioreq_request_mapcache_invalidate(const struct domain *d) { struct vcpu *v =3D current; @@ -244,7 +246,8 @@ bool vcpu_ioreq_handle_completion(struct vcpu *v) break; =20 default: - res =3D arch_vcpu_ioreq_completion(completion); + if ( arch_vcpu_ioreq_completion ) + res =3D arch_vcpu_ioreq_completion(completion); break; } =20 diff --git a/xen/include/xen/ioreq.h b/xen/include/xen/ioreq.h index cd399adf17..880214ec41 100644 --- a/xen/include/xen/ioreq.h +++ b/xen/include/xen/ioreq.h @@ -111,7 +111,7 @@ void ioreq_domain_init(struct domain *d); int ioreq_server_dm_op(struct xen_dm_op *op, struct domain *d, bool *const= _op); =20 bool arch_ioreq_complete_mmio(void); -bool arch_vcpu_ioreq_completion(enum vio_completion completion); +extern bool (*arch_vcpu_ioreq_completion)(enum vio_completion completion); int arch_ioreq_server_map_pages(struct ioreq_server *s); void arch_ioreq_server_unmap_pages(struct ioreq_server *s); void arch_ioreq_server_enable(struct ioreq_server *s); --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717414649; cv=none; d=zohomail.com; s=zohoarc; b=QIa1ALWGVsdwNiwXBqzLPcJwDbvhNHF5MrgddAFQmOc8IjF7yZ54limPeClRcjzemnxAdYSp03KJN4x2S1E8PTegpnDSwjb/0uS58s7WUwZjjMvXM0RcuUGZoC+tGJRuDa7Ta+SjcHIMTg6wRwwJJ+g5ib3/QuSNmPMF7AgY1+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717414649; h=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=1TA6QXfWBVQy8TeQASaSZnBG9i0yAv+gMoo7RfhJd1w=; b=XL99ABwkCBUM8DnnUm89uFqVXKrWwxcb0e/Ns9pI6ZWprdJ5EIsKL6mcwVHETHZnzr0NqVAdlzcpyA/x04GjNkqs6+XLVhvEn76jDOLqAMdVyKEV8K/cEJUqyN02TCDcZ4NmCG6WQw5KinYKfJKiozGgDASnwyRFnBW83MdWESo= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717414649041824.4824188068812; Mon, 3 Jun 2024 04:37:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734889.1141017 (Exim 4.92) (envelope-from ) id 1sE5zw-000310-OK; Mon, 03 Jun 2024 11:37:08 +0000 Received: by outflank-mailman (output) from mailman id 734889.1141017; Mon, 03 Jun 2024 11:37:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5zw-00030t-LO; Mon, 03 Jun 2024 11:37:08 +0000 Received: by outflank-mailman (input) for mailman id 734889; Mon, 03 Jun 2024 11:37:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sE5zv-00030l-Mv for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:37:07 +0000 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 99d37f8a-219d-11ef-90a1-e314d9c70b13; Mon, 03 Jun 2024 13:37:05 +0200 (CEST) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 17FD02757B; Mon, 3 Jun 2024 07:37:04 -0400 (EDT) (envelope-from sakib@darkstar.site) Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id F09AD2757A; Mon, 3 Jun 2024 07:37:03 -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-smtp20.pobox.com (Postfix) with ESMTPSA id 44D8E27575; Mon, 3 Jun 2024 07:36:59 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: 99d37f8a-219d-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=7Gq+t0OokvjjzhsPQkQvhI7mb 2EvEEH35F6GhZjfg/Q=; b=Z6WeutNbTMOXpf6MofM8KMl6ERm9hr1ZeKo1TPN5E rzk2K8HuLoSmf1yFjs4qaKhpp4XbHSBhnZseVu40dRX3foipQPm1BhyJtKRfaIlG 9vDwEMGAhQ57JZdo/ZEHm/1wjBSnB/ikyqNFJCSMCHm0t6wa87dO3iZ+qRDYGo/q xo= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Jan Beulich , Stefano Stabellini , Xenia Ragiadakou Subject: [XEN PATCH v3 15/16] x86/vmx: replace CONFIG_HVM with CONFIG_VMX in vmx.h Date: Mon, 3 Jun 2024 14:36:56 +0300 Message-Id: <9a1d4a9af373ff7164c20b9774eea5249af60b01.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 9740F190-219D-11EF-B366-ACC938F0AE34-90055647!pb-smtp20.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717414651235100001 Content-Type: text/plain; charset="utf-8" As now we got a separate config option for VMX which itself depends on CONFIG_HVM, we need to use it to provide vmx_pi_hooks_{assign,deassign} stubs for case when VMX is disabled while HVM is enabled. Signed-off-by: Sergiy Kibrik CC: Jan Beulich Acked-by: Jan Beulich --- changes in v3: - use CONFIG_VMX instead of CONFIG_HVM to provide stubs, instead of guardi= ng calls to vmx_pi_hooks_{assign,deassign} in iommu/vt-d code --- xen/arch/x86/include/asm/hvm/vmx/vmx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/= asm/hvm/vmx/vmx.h index 1489dd05c2..025bec2321 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -599,7 +599,7 @@ void vmx_pi_desc_fixup(unsigned int cpu); =20 void vmx_sync_exit_bitmap(struct vcpu *v); =20 -#ifdef CONFIG_HVM +#ifdef CONFIG_VMX void vmx_pi_hooks_assign(struct domain *d); void vmx_pi_hooks_deassign(struct domain *d); #else --=20 2.25.1 From nobody Fri Nov 22 23:39:03 2024 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=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1717414771; cv=none; d=zohomail.com; s=zohoarc; b=nDjESRGaZQOeU0BQ4zE0XooY4AK/MgOldTQfo7KNYcJXlPdqDcelCKIlu7FkSBHXbnbDxsOlRmqasgh7cFgQJKC6CKfn3OIykIJqUvHanP4zvzjJ3GmCZ5zVsIhulqkJZaqneyHXKwM/3ALSA6Oetck7V2cfuVNE5Tp2fHhttTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717414771; h=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=KDBabi6uGc2zQASwR9gKFCldsqAQqzvXnMdALFpDn5E=; b=f2yeTU4WqWJDz53RFNzSApAgYKHkkaRuu3X9lFeiFu8xCGodb0cpVjRdi+6hraKnfe16kxc2LXtLcpzipjFNNtAxwhbrBYmxtfJC2MCkDAGPTf0lGW1X7NNmqqQ6B0k1p4pZcGZwHdRRkHhVGQnB977pmGM1a1BUmWArsa/64A4= 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=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1717414771916184.42137162524807; Mon, 3 Jun 2024 04:39:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.734896.1141026 (Exim 4.92) (envelope-from ) id 1sE61z-0003bb-6a; Mon, 03 Jun 2024 11:39:15 +0000 Received: by outflank-mailman (output) from mailman id 734896.1141026; Mon, 03 Jun 2024 11:39: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 1sE61z-0003bU-3x; Mon, 03 Jun 2024 11:39:15 +0000 Received: by outflank-mailman (input) for mailman id 734896; Mon, 03 Jun 2024 11:39:14 +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 1sE61y-0003bO-40 for xen-devel@lists.xenproject.org; Mon, 03 Jun 2024 11:39:14 +0000 Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e4ecf6b3-219d-11ef-b4bb-af5377834399; Mon, 03 Jun 2024 13:39:11 +0200 (CEST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 126C7318B8; Mon, 3 Jun 2024 07:39:10 -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 0ACD3318B7; Mon, 3 Jun 2024 07:39:10 -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 25949318B6; Mon, 3 Jun 2024 07:39:06 -0400 (EDT) (envelope-from sakib@darkstar.site) 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: e4ecf6b3-219d-11ef-b4bb-af5377834399 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=JHgRlQ2mOAVaV36q/DwoXTgbm MjsvlXARfcG6GpvdPs=; b=rNgvOyf/nEl3Sg/AqUYANDNaMjpNMCYxrg86dVmWz 7D5eeIVOvdRNPxFY3L6gQhaqKXZW6JMp/5r8ytL1HtL1TVEtm9PFFxeie8itz5j4 CrJmrD43xLGM4A4BilgybCoJHzDFlrJeGZesI5Cad86aI/Dz3M2Qpz6nf7D/flHq m8= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Xenia Ragiadakou , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Xenia Ragiadakou , Sergiy Kibrik Subject: [XEN PATCH v3 16/16] x86/hvm: make AMD-V and Intel VT-x support configurable Date: Mon, 3 Jun 2024 14:39:03 +0300 Message-Id: <794fc2bf6cedddb9ea2ee0265e750e198d34eee9.1717410850.git.Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: E2E04B50-219D-11EF-AEB4-8F8B087618E4-90055647!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1717414773606100001 Content-Type: text/plain; charset="utf-8" From: Xenia Ragiadakou Provide the user with configuration control over the cpu virtualization sup= port in Xen by making SVM and VMX options user selectable. To preserve the current default behavior, both options depend on HVM and default to value of HVM. To prevent users from unknowingly disabling virtualization support, make the controls user selectable only if EXPERT is enabled. No functional change intended. Signed-off-by: Xenia Ragiadakou Signed-off-by: Sergiy Kibrik Reviewed-by: Stefano Stabellini Acked-by: Jan Beulich --- changes in v3: - only tags added changes in v2: - remove dependency of build options IOMMU/AMD_IOMMU on VMX/SVM options --- xen/arch/x86/Kconfig | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 4a35c43dc5..dbee7c2efb 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -123,10 +123,24 @@ config HVM If unsure, say Y. =20 config SVM - def_bool HVM + bool "AMD-V" if EXPERT + depends on HVM + default HVM + help + Enables virtual machine extensions on platforms that implement the + AMD Virtualization Technology (AMD-V). + If your system includes a processor with AMD-V support, say Y. + If in doubt, say Y. =20 config VMX - def_bool HVM + bool "Intel VT-x" if EXPERT + depends on HVM + default HVM + help + Enables virtual machine extensions on platforms that implement the + Intel Virtualization Technology (Intel VT-x). + If your system includes a processor with Intel VT-x support, say Y. + If in doubt, say Y. =20 config XEN_SHSTK bool "Supervisor Shadow Stacks" --=20 2.25.1