Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2AABCAC592 for ; Tue, 16 Sep 2025 17:14:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1124750.1466970 (Exim 4.92) (envelope-from ) id 1uyZGE-0002Vg-I6; Tue, 16 Sep 2025 17:14:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1124750.1466970; Tue, 16 Sep 2025 17:14:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uyZGE-0002VZ-Et; Tue, 16 Sep 2025 17:14:34 +0000 Received: by outflank-mailman (input) for mailman id 1124750; Tue, 16 Sep 2025 17:14:33 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uyZGD-0002VT-Om for xen-devel@lists.xenproject.org; Tue, 16 Sep 2025 17:14:33 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1uyZGA-00Ct9c-0X; Tue, 16 Sep 2025 17:14:30 +0000 Received: from [149.199.65.200] (helo=[10.10.151.52]) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uyZGA-00CzYu-0u; Tue, 16 Sep 2025 17:14:30 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=EOMrII1z1zQLRHCl1sFMtAmD+D/WioEXgF5lO/GymEY=; b=wcsUuFAEycHnTVEzJBexSJV0HW GW4wjy/rEzIXnXs+mJRZ/aw3j7Ht/yxW9dV76O7ZlvyPmPYmjuBNkVsrX4QQh1SQbt4gTH8L+Qtit XxK1l/6Kglqw8F7ZDYgi13qB8o30tZnWZjJ8q3Zc3SOevd4VPhNRpK3PzaUR7pEWBv1g=; Message-ID: <88cc4cf1-3bc9-47f5-b8f7-e04f01b027ee@xen.org> Date: Tue, 16 Sep 2025 10:14:29 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [XEN][PATCH 1/2] x86: hvm: vmx: fix runtime vmx presence check for !CONFIG_INTEL_VMX case To: Grygorii Strashko , Jan Beulich Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Alejandro Vallejo , Oleksii Kurochko , "xen-devel@lists.xenproject.org" References: <20250916103251.2144449-1-grygorii_strashko@epam.com> <3baf457c-d32b-4965-96bb-022a2f92bb9d@suse.com> Content-Language: en-GB From: Andrew Cooper In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 16/09/2025 9:57 am, Grygorii Strashko wrote: > Hi Jan, > > On 16.09.25 17:34, Jan Beulich wrote: >> On 16.09.2025 12:32, Grygorii Strashko wrote: >>> From: Grygorii Strashko >>> >>> Since commit b99227347230 ("x86: Fix AMD_SVM and INTEL_VMX >>> dependency") the >>> HVM Intel VT-x support can be gracefully disabled, but it still >>> keeps VMX >>> code partially built-in, because HVM code uses mix of: >>> >>>   - "cpu_has_vmx" macro, which doesn't account for CONFIG_INTEL_VMX cfg >>>   - "using_vmx()" function, which accounts for CONFIG_INTEL_VMX cfg >>> >>> for runtime VMX availability checking. As result compiler DCE can't >>> remove >>> all, unreachable VMX code. >>> >>> Fix it by sticking to "cpu_has_vmx" macro usage only which is >>> updated to >>> account CONFIG_INTEL_VMX cfg. >>> >>> Signed-off-by: Grygorii Strashko >>> --- >>> Hi >>> >>> It could be good to have it in 4.21, so vmx/svm disabling >>> option will be in complete state within 4.21 version. >> >> Imo this isn't release critical and has come too late. It's of course >> Oleksii's call in the end. >> >>> --- a/xen/arch/x86/include/asm/cpufeature.h >>> +++ b/xen/arch/x86/include/asm/cpufeature.h >>> @@ -136,7 +136,8 @@ static inline bool boot_cpu_has(unsigned int feat) >>>   #define cpu_has_sse3            boot_cpu_has(X86_FEATURE_SSE3) >>>   #define cpu_has_pclmulqdq       boot_cpu_has(X86_FEATURE_PCLMULQDQ) >>>   #define cpu_has_monitor         boot_cpu_has(X86_FEATURE_MONITOR) >>> -#define cpu_has_vmx             boot_cpu_has(X86_FEATURE_VMX) >>> +#define cpu_has_vmx             (IS_ENABLED(CONFIG_INTEL_VMX) && \ >>> +                                 boot_cpu_has(X86_FEATURE_VMX)) >> >> I'm pretty sure using_vmx() was introduced precisely to avoid the use of >> IS_ENABLED() here. What is completely missing from the description is a >> discussion of the effect of this change on pre-existing uses of the >> macro. ISTR there being at least one instance which would break with >> that change. And no, I'm not looking forward to digging that out again, >> when I already did at the time the using_vmx() was suggested and then >> implemented. (I can't exclude it was the SVM counterpart; we want to >> keep both in sync in any event, imo.) > > Thank you for your comments and sorry for not digging into the history of > the related patches. > > All, please ignore these patches as existing places. where > cpu_has_vmx/smv > are still used, need to be revised one by one. > Off the top of my head, fixups to MSR_FEATURE_CONTROL, and AMD SKINIT need cpu_has_vmx/svm not guarded by Kconfig like this. ~Andrew