diff mbox series

[XEN,v4,06/14] x86/p2m: guard EPT functions with using_vmx() check

Message ID d51ae897890ec01de70c44d15450e888f84d34c4.1720501197.git.Sergiy_Kibrik@epam.com (mailing list archive)
State Superseded
Headers show
Series x86: make CPU virtualisation support configurable | expand

Commit Message

Sergiy Kibrik July 9, 2024, 5:56 a.m. UTC
From: Xenia Ragiadakou <burzalodowa@gmail.com>

Replace cpu_has_vmx check with using_vmx(), so that we do check if functions
ept_p2m_init() and ept_p2m_uninit() can be called.
Since currently Intel EPT implementation depends on CONFIG_VMX config option,
when VMX is off these functions are unavailable.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
changes in v4:
 - changed description a bit
 - added tag
 - adjusted call to using_vmx(), as it has become an inline function
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(-)

Comments

Jan Beulich July 9, 2024, 7:19 a.m. UTC | #1
On 09.07.2024 07:56, Sergiy Kibrik wrote:
> From: Xenia Ragiadakou <burzalodowa@gmail.com>
> 
> Replace cpu_has_vmx check with using_vmx(), so that we do check if functions
> ept_p2m_init() and ept_p2m_uninit() can be called.

I still find this an odd way of putting it. Source code ...

> --- 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_domain *p2m)
>      p2m_pod_init(p2m);
>      p2m_nestedp2m_init(p2m);
>  
> -    if ( hap_enabled(d) && cpu_has_vmx )
> +    if ( hap_enabled(d) && using_vmx() )
>          ret = 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);

... is very clear about them being called. What you're after is the compiler
DCEing the calls in generated code.

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/mm/p2m-basic.c b/xen/arch/x86/mm/p2m-basic.c
index 08007a687c..e126fda267 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_domain *p2m)
     p2m_pod_init(p2m);
     p2m_nestedp2m_init(p2m);
 
-    if ( hap_enabled(d) && cpu_has_vmx )
+    if ( hap_enabled(d) && using_vmx() )
         ret = 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);