Re: [Xen-devel] [PATCH 15/34] x86/nestedhvm: make it build with !CONFIG_HVM

2018-08-20 Thread Jan Beulich
>>> On 17.08.18 at 17:12,  wrote:

The title isn't very consistent within itself: Nested-HVM code is certainly
not to be built without CONFIG_HVM.

> @@ -70,7 +74,18 @@ unsigned long *nestedhvm_vcpu_iomap_get(bool_t ioport_80, 
> bool_t ioport_ed);
>  
>  void nestedhvm_vmcx_flushtlb(struct p2m_domain *p2m);
>  
> -bool_t nestedhvm_is_n2(struct vcpu *v);
> +static inline bool nestedhvm_is_n2(struct vcpu *v)

I'm tempted to suggest the parameter could be constified, but it
looks like this would require some const additions elsewhere first.

> +{
> +if ( !nestedhvm_enabled(v->domain) ||
> +nestedhvm_vmswitch_in_progress(v) ||
> +!nestedhvm_paging_mode_hap(v) )
> +return false;
> +
> +if ( nestedhvm_vcpu_in_guestmode(v) )
> +return true;
> +
> +return false;

Can the last four lines be a single return statement please? With
that
Acked-by: Jan Beulich 

Jan



___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH 15/34] x86/nestedhvm: make it build with !CONFIG_HVM

2018-08-17 Thread Wei Liu
Make two functions static inline so that they can be referenced in p2m
code. Check nestedhvm is enabled before calling
nestedhvm_vmcx_flushtlb (which also has a side effect of not issuing
unnecessary IPIs for non-nested case).

While moving, reformat code and use proper boolean.

Signed-off-by: Wei Liu 
---
 xen/arch/x86/hvm/nestedhvm.c| 21 -
 xen/arch/x86/mm/p2m.c   |  3 ++-
 xen/include/asm-x86/hvm/nestedhvm.h | 19 +--
 3 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/xen/arch/x86/hvm/nestedhvm.c b/xen/arch/x86/hvm/nestedhvm.c
index ab50b2a..bd11019 100644
--- a/xen/arch/x86/hvm/nestedhvm.c
+++ b/xen/arch/x86/hvm/nestedhvm.c
@@ -26,13 +26,6 @@
 
 static unsigned long *shadow_io_bitmap[3];
 
-/* Nested HVM on/off per domain */
-bool nestedhvm_enabled(const struct domain *d)
-{
-return is_hvm_domain(d) && d->arch.hvm_domain.params &&
-d->arch.hvm_domain.params[HVM_PARAM_NESTEDHVM];
-}
-
 /* Nested VCPU */
 bool_t
 nestedhvm_vcpu_in_guestmode(struct vcpu *v)
@@ -120,20 +113,6 @@ nestedhvm_vmcx_flushtlb(struct p2m_domain *p2m)
 cpumask_clear(p2m->dirty_cpumask);
 }
 
-bool_t
-nestedhvm_is_n2(struct vcpu *v)
-{
-if (!nestedhvm_enabled(v->domain)
-  || nestedhvm_vmswitch_in_progress(v)
-  || !nestedhvm_paging_mode_hap(v))
-return 0;
-
-if (nestedhvm_vcpu_in_guestmode(v))
-return 1;
-
-return 0;
-}
-
 /* Common shadow IO Permission bitmap */
 
 /* There four global patterns of io bitmap each guest can
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 8e9fbb5..1089b86 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1756,7 +1756,8 @@ p2m_flush_table_locked(struct p2m_domain *p2m)
 p2m->np2m_generation++;
 
 /* Make sure nobody else is using this p2m table */
-nestedhvm_vmcx_flushtlb(p2m);
+if ( nestedhvm_enabled(d) )
+nestedhvm_vmcx_flushtlb(p2m);
 
 /* Zap the top level of the trie */
 mfn = pagetable_get_mfn(p2m_get_pagetable(p2m));
diff --git a/xen/include/asm-x86/hvm/nestedhvm.h 
b/xen/include/asm-x86/hvm/nestedhvm.h
index 47165fc..c7003dd 100644
--- a/xen/include/asm-x86/hvm/nestedhvm.h
+++ b/xen/include/asm-x86/hvm/nestedhvm.h
@@ -33,7 +33,11 @@ enum nestedhvm_vmexits {
 };
 
 /* Nested HVM on/off per domain */
-bool nestedhvm_enabled(const struct domain *d);
+static inline bool nestedhvm_enabled(const struct domain *d)
+{
+return is_hvm_domain(d) && d->arch.hvm_domain.params &&
+d->arch.hvm_domain.params[HVM_PARAM_NESTEDHVM];
+}
 
 /* Nested VCPU */
 int nestedhvm_vcpu_initialise(struct vcpu *v);
@@ -70,7 +74,18 @@ unsigned long *nestedhvm_vcpu_iomap_get(bool_t ioport_80, 
bool_t ioport_ed);
 
 void nestedhvm_vmcx_flushtlb(struct p2m_domain *p2m);
 
-bool_t nestedhvm_is_n2(struct vcpu *v);
+static inline bool nestedhvm_is_n2(struct vcpu *v)
+{
+if ( !nestedhvm_enabled(v->domain) ||
+nestedhvm_vmswitch_in_progress(v) ||
+!nestedhvm_paging_mode_hap(v) )
+return false;
+
+if ( nestedhvm_vcpu_in_guestmode(v) )
+return true;
+
+return false;
+}
 
 static inline void nestedhvm_set_cr(struct vcpu *v, unsigned int cr,
 unsigned long value)
-- 
git-series 0.9.1

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel