[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN][PATCH 1/2] x86: hvm: vmx: fix runtime vmx presence check for !CONFIG_INTEL_VMX case


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Tue, 16 Sep 2025 19:57:31 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g5uYeXa3i9VaZACp93bIk8qhtw6G0YlYhQ16KKrxULw=; b=WqihaDziY7AsR0FteMVw7WXxVOrwDZnqc1Sf2Zs5cturMAwQ5F2+ZWPbgOMw2iTmZp9EU7rpois5GvOBM1RKNS8NVkuInMjT46PELwLaJ3eQNGcrGM05JgHbs53KwA49ZSbi5B+IeHs5fKOSkkLOEOtfm8S9vltzT05SzIxP4xK4BvnY5QxId+LzBGZu37Q4dAB2vS0F9pTQnp5RShv7HRjQ1mZBmYFKMYLGp55zRO7sXlembBtZH+SeX5A+cIPOPHQcISPDYbzE5U2oai6dd6E94HdZImc/gz3HyOCLBfs0ABujhw8jvHeK+ks4jIgdlq4pi50n5lbUVoJFj2JRAQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LBxKqCnktg2oZLXt6La/NcAzRsU/IvVbhozorCnRd3VwHkC0yodu0BiRizQFm7EDQMDQySGcCyxRuTfklOezTpoJQYff903GnWNV+fsXFa5L75sxYisM9D+8+qvQ57hA9C0axSf+QyfO1tf25ZCPDWCfjJQfTgR1VxeoqYR2Jo6HtBKVB7Lcwhl7BbXKI80WTa+vbSenf6E27Jy+RSLzn6iLgAV1cFyrL9TjCpBeQCO66Z/iWomhwjTIVD8oM5XAGv5nj4TqQapDQDQJzhD65eaGMhhXZZrKnTbBOTkusZuxIaoY5HLlEE+068B0sdvWf1gq/GjwIgb0Ig+CjUfEbw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 16 Sep 2025 16:58:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jan,

On 16.09.25 17:34, Jan Beulich wrote:
On 16.09.2025 12:32, Grygorii Strashko wrote:
From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

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 <grygorii_strashko@xxxxxxxx>
---
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.

--
Best regards,
-grygorii




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.