]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
x86/nestedhvm: provide some stubs for p2m code
authorWei Liu <wei.liu2@citrix.com>
Mon, 13 Aug 2018 14:02:32 +0000 (15:02 +0100)
committerWei Liu <wei.liu2@citrix.com>
Sun, 26 Aug 2018 10:01:03 +0000 (11:01 +0100)
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 <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/nestedhvm.c
xen/arch/x86/mm/p2m.c
xen/include/asm-x86/hvm/nestedhvm.h

index ab50b2ab9882e39cc2fb2217ff8a3baae5e4cbaf..bd1101987de03b9806c6b98d40eacc780b34bfc3 100644 (file)
 
 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
index 8e9fbb5a146fa0bcc7164021e94e066e80aac166..1089b865054121feb3c6a355646076934e3c8073 100644 (file)
@@ -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));
index 47165fcb96e7aecb5870b8dc3c34e78fbd041b5f..3c810b72f01e31fab84443c9e90a74357dae1bbc 100644 (file)
@@ -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,15 @@ 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;
+
+    return nestedhvm_vcpu_in_guestmode(v);
+}
 
 static inline void nestedhvm_set_cr(struct vcpu *v, unsigned int cr,
                                     unsigned long value)