[XEN][PATCH] x86/hvm: mem_sharing: add dependency from CONFIG_INTEL_VMX

Grygorii Strashko posted 1 patch 1 week, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20250925195607.521021-1-grygorii._5Fstrashko@epam.com
xen/arch/x86/hvm/Kconfig | 1 +
1 file changed, 1 insertion(+)
[XEN][PATCH] x86/hvm: mem_sharing: add dependency from CONFIG_INTEL_VMX
Posted by Grygorii Strashko 1 week, 2 days ago
From: Grygorii Strashko <grygorii_strashko@epam.com>

According to the commit b66e28226dd9 ("x86/mem_sharing: gate enabling on
cpu_has_vmx") the Xen memory sharing support is only possible on platforms
with "Intel VT-x" (INTEL_VMX=y) enabled.
The same commit is also added runtime check for "cpu_has_vmx" in
mem_sharing_control() which blocks access to XENMEM_sharing_ops if
!cpu_has_vmx.

Hence add dependency from INTEL_VMX for MEM_SHARING Kconfig option.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
It has took me a time (including digging deep in git history) to understand
presence of this dependency, so this patch. Hope it helps other people and they
will not need waste their time digging.

 xen/arch/x86/hvm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/arch/x86/hvm/Kconfig b/xen/arch/x86/hvm/Kconfig
index aed799fcb9c2..d62492d2043c 100644
--- a/xen/arch/x86/hvm/Kconfig
+++ b/xen/arch/x86/hvm/Kconfig
@@ -79,5 +79,6 @@ config MEM_PAGING
 
 config MEM_SHARING
 	bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED
+	depends on INTEL_VMX
 
 endif
-- 
2.34.1
Re: [XEN][PATCH] x86/hvm: mem_sharing: add dependency from CONFIG_INTEL_VMX
Posted by Jan Beulich 1 week, 1 day ago
On 25.09.2025 21:56, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> According to the commit b66e28226dd9 ("x86/mem_sharing: gate enabling on
> cpu_has_vmx") the Xen memory sharing support is only possible on platforms
> with "Intel VT-x" (INTEL_VMX=y) enabled.
> The same commit is also added runtime check for "cpu_has_vmx" in
> mem_sharing_control() which blocks access to XENMEM_sharing_ops if
> !cpu_has_vmx.
> 
> Hence add dependency from INTEL_VMX for MEM_SHARING Kconfig option.
> 
> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

You should have Cc-ed Tamas, for being the maintainer of mem-sharing.

> --- a/xen/arch/x86/hvm/Kconfig
> +++ b/xen/arch/x86/hvm/Kconfig
> @@ -79,5 +79,6 @@ config MEM_PAGING
>  
>  config MEM_SHARING
>  	bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED
> +	depends on INTEL_VMX
>  
>  endif

Wouldn't this want accompanying by replacing the cpu_has_vmx in
mem_sharing_control() with using_vmx()? The gain in this case may not
be very high, but it would serve a doc purpose.

Jan
Re: [XEN][PATCH] x86/hvm: mem_sharing: add dependency from CONFIG_INTEL_VMX
Posted by Grygorii Strashko 1 week, 1 day ago

On 26.09.25 09:37, Jan Beulich wrote:
> On 25.09.2025 21:56, Grygorii Strashko wrote:
>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>
>> According to the commit b66e28226dd9 ("x86/mem_sharing: gate enabling on
>> cpu_has_vmx") the Xen memory sharing support is only possible on platforms
>> with "Intel VT-x" (INTEL_VMX=y) enabled.
>> The same commit is also added runtime check for "cpu_has_vmx" in
>> mem_sharing_control() which blocks access to XENMEM_sharing_ops if
>> !cpu_has_vmx.
>>
>> Hence add dependency from INTEL_VMX for MEM_SHARING Kconfig option.
>>
>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> You should have Cc-ed Tamas, for being the maintainer of mem-sharing.

Sorry, I relied on add_maintainers.pl script.

> 
>> --- a/xen/arch/x86/hvm/Kconfig
>> +++ b/xen/arch/x86/hvm/Kconfig
>> @@ -79,5 +79,6 @@ config MEM_PAGING
>>   
>>   config MEM_SHARING
>>   	bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED
>> +	depends on INTEL_VMX
>>   
>>   endif
> 
> Wouldn't this want accompanying by replacing the cpu_has_vmx in
> mem_sharing_control() with using_vmx()? The gain in this case may not
> be very high, but it would serve a doc purpose.

There are no benefits. if !INTEL_VMX the whole module will excluded from build,
if INTEL_VMX - it will end up calling "cpu_has_vmx".

What, potentially, might make sense is to move mem sharing code to HVM
x86/mm/mem_sharing.c -> x86/x86/hvm/mm/mem_sharing.c

As it is strictly HVM specific. Just is potential TODO item.

-- 
Best regards,
-grygorii