[PATCH v3 02/28] xen/mem_sharing: wrap hvm_copy_context_and_params() with CONFIG_MEM_SHARING

Penny Zheng posted 28 patches 2 weeks, 3 days ago
Only 27 patches received!
[PATCH v3 02/28] xen/mem_sharing: wrap hvm_copy_context_and_params() with CONFIG_MEM_SHARING
Posted by Penny Zheng 2 weeks, 3 days ago
The only reference of hvm_copy_context_and_params() is in
arch/x86/mm/mem_sharing.c, so it shall be wrapped with CONFIG_MEM_SHARING.
Otherwise it will become unreachable when MEM_SHARING=n, and hence violating
Misra rule 2.1.

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
v2 -> v3:
- new commit
---
 xen/arch/x86/hvm/hvm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0c60faa39d..239cd992a4 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5458,6 +5458,7 @@ void hvm_set_segment_register(struct vcpu *v, enum x86_segment seg,
     alternative_vcall(hvm_funcs.set_segment_register, v, seg, reg);
 }
 
+#ifdef CONFIG_MEM_SHARING
 int hvm_copy_context_and_params(struct domain *dst, struct domain *src)
 {
     struct hvm_domain_context c = { .size = hvm_save_size(src) };
@@ -5489,6 +5490,7 @@ int hvm_copy_context_and_params(struct domain *dst, struct domain *src)
 
     return rc;
 }
+#endif /* CONFIG_MEM_SHARING */
 
 /*
  * Local variables:
-- 
2.34.1
Re: [PATCH v3 02/28] xen/mem_sharing: wrap hvm_copy_context_and_params() with CONFIG_MEM_SHARING
Posted by Jan Beulich 2 days, 2 hours ago
On 13.10.2025 12:15, Penny Zheng wrote:
> The only reference of hvm_copy_context_and_params() is in
> arch/x86/mm/mem_sharing.c, so it shall be wrapped with CONFIG_MEM_SHARING.
> Otherwise it will become unreachable when MEM_SHARING=n, and hence violating
> Misra rule 2.1.
> 
> Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
Re: [PATCH v3 02/28] xen/mem_sharing: wrap hvm_copy_context_and_params() with CONFIG_MEM_SHARING
Posted by Grygorii Strashko 2 weeks, 2 days ago

On 13.10.25 13:15, Penny Zheng wrote:
> The only reference of hvm_copy_context_and_params() is in
> arch/x86/mm/mem_sharing.c, so it shall be wrapped with CONFIG_MEM_SHARING.
> Otherwise it will become unreachable when MEM_SHARING=n, and hence violating
> Misra rule 2.1.
> 
> Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
> ---
> v2 -> v3:
> - new commit
> ---
>   xen/arch/x86/hvm/hvm.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 0c60faa39d..239cd992a4 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -5458,6 +5458,7 @@ void hvm_set_segment_register(struct vcpu *v, enum x86_segment seg,
>       alternative_vcall(hvm_funcs.set_segment_register, v, seg, reg);
>   }
>   
> +#ifdef CONFIG_MEM_SHARING
>   int hvm_copy_context_and_params(struct domain *dst, struct domain *src)
>   {
>       struct hvm_domain_context c = { .size = hvm_save_size(src) };
> @@ -5489,6 +5490,7 @@ int hvm_copy_context_and_params(struct domain *dst, struct domain *src)
>   
>       return rc;
>   }
> +#endif /* CONFIG_MEM_SHARING */
>   
>   /*
>    * Local variables:

Thank you.

Reviewed-by: Grygorii Strashko <grygorii_strashko@epam.com>

-- 
Best regards,
-grygorii