All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] Make CONFIG_HVM work
@ 2018-09-13 16:38 Wei Liu
  2018-09-13 16:38 ` [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM Wei Liu
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Wei Liu @ 2018-09-13 16:38 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu

This series goes through x86 code to make CONFIG_HVM work.

With this series, it is possible to build Xen with PV support only.

See cover letters from previous versions for more details.

Wei.

Wei Liu (7):
  x86/p2m/pod: make it build with !CONFIG_HVM
  x86: provide stubs, declarations and macros in hvm.h
  x86/mm: put nested p2m code under CONFIG_HVM
  x86/mm: put HVM only code under CONFIG_HVM
  x86/mm: put paging_update_nestedmode under CONFIG_HVM
  xen: connect guest creation with CONFIG_HVM
  x86: expose CONFIG_HVM

 xen/arch/x86/Kconfig             |  10 +++-
 xen/arch/x86/domain.c            |   4 +-
 xen/arch/x86/domctl.c            |   2 +-
 xen/arch/x86/mm.c                |   2 +-
 xen/arch/x86/mm/Makefile         |  11 +--
 xen/arch/x86/mm/mem_access.c     |  18 +++++-
 xen/arch/x86/mm/mem_sharing.c    |   2 +-
 xen/arch/x86/mm/p2m-pt.c         |   4 +-
 xen/arch/x86/mm/p2m.c            |  67 +++++++++++++++------
 xen/arch/x86/mm/paging.c         |   2 +-
 xen/common/domain.c              |   7 ++-
 xen/common/memory.c              |   3 +-
 xen/common/vm_event.c            |   6 +-
 xen/include/asm-x86/altp2m.h     |  13 +++-
 xen/include/asm-x86/domain.h     |   2 +-
 xen/include/asm-x86/hvm/domain.h |   4 +-
 xen/include/asm-x86/hvm/hvm.h    | 104 ++++++++++++++++++++++++++++++++-
 xen/include/asm-x86/p2m.h        |  48 +++++++++++++--
 18 files changed, 275 insertions(+), 34 deletions(-)

base-commit: 1c21390736524e1fdf7f99816ac54ae85aa9673c
-- 
git-series 0.9.1

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM
  2018-09-13 16:38 [PATCH v4 0/7] Make CONFIG_HVM work Wei Liu
@ 2018-09-13 16:38 ` Wei Liu
  2018-09-13 16:56   ` Tamas K Lengyel
  2018-09-14 12:41   ` Jan Beulich
  2018-09-13 16:38 ` [PATCH v4 2/7] x86: provide stubs, declarations and macros in hvm.h Wei Liu
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 19+ messages in thread
From: Wei Liu @ 2018-09-13 16:38 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Razvan Cojocaru,
	Konrad Rzeszutek Wilk, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, Julien Grall, Tamas K Lengyel, Jan Beulich

Populate-on-demand is HVM only.

Provide a bunch of stubs for common p2m code and guard one invocation
of guest_physmap_mark_populate_on_demand with is_hvm_domain.

Put relevant fields in p2m_domain and code which touches those fields
under CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v4:
1. Factor out p2m_pod_init.
2. Put audit_p2m under CONFIG_HVM.
3. Get rid of one local variable to simplify code.

v3: Put pod related fields and code under CONFIG_HVM.
---
 xen/arch/x86/domctl.c     |  2 +-
 xen/arch/x86/mm.c         |  2 ++
 xen/arch/x86/mm/p2m-pt.c  |  4 ++++
 xen/arch/x86/mm/p2m.c     | 29 ++++++++++++++++++++++-------
 xen/common/memory.c       |  3 ++-
 xen/common/vm_event.c     |  6 +++---
 xen/include/asm-x86/p2m.h | 38 ++++++++++++++++++++++++++++++++++----
 7 files changed, 68 insertions(+), 16 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 2284128..115ddf6 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1221,7 +1221,7 @@ long arch_do_domctl(
         ret = mem_sharing_domctl(d, &domctl->u.mem_sharing_op);
         break;
 
-#if P2M_AUDIT
+#if P2M_AUDIT && defined(CONFIG_HVM)
     case XEN_DOMCTL_audit_p2m:
         if ( d == currd )
             ret = -EPERM;
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index d37eea5..bbb7ff5 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4630,6 +4630,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         return 0;
     }
 
+#ifdef CONFIG_HVM
     case XENMEM_set_pod_target:
     case XENMEM_get_pod_target:
     {
@@ -4686,6 +4687,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         rcu_unlock_domain(d);
         return rc;
     }
+#endif
 
     default:
         return subarch_memory_op(cmd, arg);
diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c
index b8c5d2e..74884ea 100644
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -974,7 +974,9 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
     unsigned long mfn, gfn, m2pfn;
 
     ASSERT(p2m_locked_by_me(p2m));
+#ifdef CONFIG_HVM
     ASSERT(pod_locked_by_me(p2m));
+#endif
 
     /* Audit part one: walk the domain's p2m table, checking the entries. */
     if ( pagetable_get_pfn(p2m_get_pagetable(p2m)) != 0 )
@@ -1105,6 +1107,7 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
         unmap_domain_page(l4e);
     }
 
+#ifdef CONFIG_HVM
     if ( entry_count != p2m->pod.entry_count )
     {
         printk("%s: refcounted entry count %ld, audit count %lu!\n",
@@ -1113,6 +1116,7 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
                entry_count);
         BUG();
     }
+#endif
 
     return pmbad;
 }
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 6020553..80b7293 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -49,18 +49,28 @@ boolean_param("hap_2mb", opt_hap_2mb);
 
 DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock);
 
+static void p2m_pod_init(struct p2m_domain *p2m)
+{
+#ifdef CONFIG_HVM
+    unsigned int i;
+
+    mm_lock_init(&p2m->pod.lock);
+    INIT_PAGE_LIST_HEAD(&p2m->pod.super);
+    INIT_PAGE_LIST_HEAD(&p2m->pod.single);
+
+    for ( i = 0; i < ARRAY_SIZE(p2m->pod.mrp.list); ++i )
+        p2m->pod.mrp.list[i] = gfn_x(INVALID_GFN);
+#endif
+}
+
 /* Init the datastructures for later use by the p2m code */
 static int p2m_initialise(struct domain *d, struct p2m_domain *p2m)
 {
-    unsigned int i;
     int ret = 0;
 
     mm_rwlock_init(&p2m->lock);
-    mm_lock_init(&p2m->pod.lock);
     INIT_LIST_HEAD(&p2m->np2m_list);
     INIT_PAGE_LIST_HEAD(&p2m->pages);
-    INIT_PAGE_LIST_HEAD(&p2m->pod.super);
-    INIT_PAGE_LIST_HEAD(&p2m->pod.single);
 
     p2m->domain = d;
     p2m->default_access = p2m_access_rwx;
@@ -69,8 +79,7 @@ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m)
     p2m->np2m_base = P2M_BASE_EADDR;
     p2m->np2m_generation = 0;
 
-    for ( i = 0; i < ARRAY_SIZE(p2m->pod.mrp.list); ++i )
-        p2m->pod.mrp.list[i] = gfn_x(INVALID_GFN);
+    p2m_pod_init(p2m);
 
     if ( hap_enabled(d) && cpu_has_vmx )
         ret = ept_p2m_init(p2m);
@@ -917,6 +926,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
                  gfn_x(gfn), mfn_x(mfn));
         rc = p2m_set_entry(p2m, gfn, INVALID_MFN, page_order,
                            p2m_invalid, p2m->default_access);
+#ifdef CONFIG_HVM
         if ( rc == 0 )
         {
             pod_lock(p2m);
@@ -924,6 +934,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
             BUG_ON(p2m->pod.entry_count < 0);
             pod_unlock(p2m);
         }
+#endif
     }
 
 out:
@@ -1114,6 +1125,7 @@ static int set_typed_p2m_entry(struct domain *d, unsigned long gfn_l,
     if ( rc )
         gdprintk(XENLOG_ERR, "p2m_set_entry: %#lx:%u -> %d (0x%"PRI_mfn")\n",
                  gfn_l, order, rc, mfn_x(mfn));
+#ifdef CONFIG_HVM
     else if ( p2m_is_pod(ot) )
     {
         pod_lock(p2m);
@@ -1121,6 +1133,7 @@ static int set_typed_p2m_entry(struct domain *d, unsigned long gfn_l,
         BUG_ON(p2m->pod.entry_count < 0);
         pod_unlock(p2m);
     }
+#endif
     gfn_unlock(p2m, gfn, order);
 
     return rc;
@@ -1743,9 +1756,11 @@ p2m_flush_table_locked(struct p2m_domain *p2m)
      * when discarding them.
      */
     ASSERT(!p2m_is_hostp2m(p2m));
+#ifdef CONFIG_HVM
     /* Nested p2m's do not do pod, hence the asserts (and no pod lock)*/
     ASSERT(page_list_empty(&p2m->pod.super));
     ASSERT(page_list_empty(&p2m->pod.single));
+#endif
 
     /* No need to flush if it's already empty */
     if ( p2m_is_nestedp2m(p2m) && p2m->np2m_base == P2M_BASE_EADDR )
@@ -2539,7 +2554,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn,
 
 /*** Audit ***/
 
-#if P2M_AUDIT
+#if P2M_AUDIT && defined(CONFIG_HVM)
 void audit_p2m(struct domain *d,
                uint64_t *orphans,
                 uint64_t *m2p_bad,
diff --git a/xen/common/memory.c b/xen/common/memory.c
index 996f94b..5c71ce1 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -210,7 +210,8 @@ static void populate_physmap(struct memop_args *a)
             if ( d == curr_d )
                 goto out;
 
-            if ( guest_physmap_mark_populate_on_demand(d, gpfn,
+            if ( is_hvm_domain(d) &&
+                 guest_physmap_mark_populate_on_demand(d, gpfn,
                                                        a->extent_order) < 0 )
                 goto out;
         }
diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
index 4793aac..50d5ebc 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -630,8 +630,6 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec,
         {
         case XEN_VM_EVENT_ENABLE:
         {
-            struct p2m_domain *p2m = p2m_get_hostp2m(d);
-
             rc = -EOPNOTSUPP;
             /* hvm fixme: p2m_is_foreign types need addressing */
             if ( is_hvm_domain(hardware_domain) )
@@ -647,10 +645,12 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec,
             if ( unlikely(need_iommu(d)) )
                 break;
 
+#ifdef CONFIG_HVM
             rc = -EXDEV;
             /* Disallow paging in a PoD guest */
-            if ( p2m->pod.entry_count )
+            if ( p2m_get_hostp2m(d)->pod.entry_count )
                 break;
+#endif
 
             /* domain_pause() not required here, see XSA-99 */
             rc = vm_event_enable(d, vec, &d->vm_event_paging, _VPF_mem_paging,
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index d4b3cfc..3785598 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -306,6 +306,7 @@ struct p2m_domain {
      * to resume the search */
     unsigned long next_shared_gfn_to_relinquish;
 
+#ifdef CONFIG_HVM
     /* Populate-on-demand variables
      * All variables are protected with the pod lock. We cannot rely on
      * the p2m lock if it's turned into a fine-grained lock.
@@ -337,6 +338,8 @@ struct p2m_domain {
         mm_lock_t        lock;         /* Locking of private pod structs,   *
                                         * not relying on the p2m lock.      */
     } pod;
+#endif
+
     union {
         struct ept_data ept;
         /* NPT-equivalent structure could be added here. */
@@ -646,6 +649,12 @@ int p2m_add_foreign(struct domain *tdom, unsigned long fgfn,
 /* Dump PoD information about the domain */
 void p2m_pod_dump_data(struct domain *d);
 
+#ifdef CONFIG_HVM
+
+/* Called by p2m code when demand-populating a PoD page */
+bool
+p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, unsigned int order);
+
 /* Move all pages from the populate-on-demand cache to the domain page_list
  * (usually in preparation for domain destruction) */
 int p2m_pod_empty_cache(struct domain *d);
@@ -662,6 +671,31 @@ p2m_pod_offline_or_broken_hit(struct page_info *p);
 void
 p2m_pod_offline_or_broken_replace(struct page_info *p);
 
+#else
+
+static inline bool
+p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, unsigned int order)
+{
+    return false;
+}
+
+static inline int p2m_pod_empty_cache(struct domain *d)
+{
+    return 0;
+}
+
+static inline int p2m_pod_offline_or_broken_hit(struct page_info *p)
+{
+    return 0;
+}
+
+static inline void p2m_pod_offline_or_broken_replace(struct page_info *p)
+{
+    ASSERT_UNREACHABLE();
+}
+
+#endif
+
 
 /*
  * Paging to disk and page-sharing
@@ -730,10 +764,6 @@ extern void audit_p2m(struct domain *d,
 #define P2M_DEBUG(f, a...) do { (void)(f); } while(0)
 #endif
 
-/* Called by p2m code when demand-populating a PoD page */
-bool
-p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, unsigned int order);
-
 /*
  * Functions specific to the p2m-pt implementation
  */
-- 
git-series 0.9.1

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 2/7] x86: provide stubs, declarations and macros in hvm.h
  2018-09-13 16:38 [PATCH v4 0/7] Make CONFIG_HVM work Wei Liu
  2018-09-13 16:38 ` [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM Wei Liu
@ 2018-09-13 16:38 ` Wei Liu
  2018-09-14 12:44   ` Jan Beulich
  2018-09-13 16:38 ` [PATCH v4 3/7] x86/mm: put nested p2m code under CONFIG_HVM Wei Liu
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2018-09-13 16:38 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

Make sure hvm_enabled evaluate to false then provide necessary things
to make xen build when !CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v4:
1. Add more comments.
2. Reshuffle sections a bit.
3. Don't use gcc extension, use comma expression instead.
4. Adjustment to functions prototypes.
---
 xen/include/asm-x86/hvm/hvm.h | 104 +++++++++++++++++++++++++++++++++++-
 1 file changed, 104 insertions(+)

diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index 0c32140..bf8e76f 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -340,6 +340,9 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
                            signed int cr0_pg);
 unsigned long hvm_cr4_guest_valid_bits(const struct domain *d, bool restore);
 
+
+#ifdef CONFIG_HVM
+
 #define hvm_get_guest_tsc(v) hvm_get_guest_tsc_fixed(v, 0)
 
 #define hvm_tsc_scaling_supported \
@@ -675,6 +678,107 @@ static inline bool altp2m_vcpu_emulate_ve(struct vcpu *v)
         d_->arch.hvm.pi_ops.vcpu_block(v_);                     \
 })
 
+#else  /* CONFIG_HVM */
+
+#define hvm_enabled false
+
+/*
+ * List of inline functions above, of which only declarations are
+ * needed because DCE will kick in.
+ */
+int hvm_guest_x86_mode(struct vcpu *v);
+unsigned long hvm_get_shadow_gs_base(struct vcpu *v);
+void hvm_set_info_guest(struct vcpu *v);
+void hvm_cpuid_policy_changed(struct vcpu *v);
+void hvm_set_tsc_offset(struct vcpu *v, uint64_t offset, uint64_t at_tsc);
+
+/* End of prototype list */
+
+/* Called by code in other header  */
+static inline bool hvm_is_singlestep_supported(void)
+{
+    return false;
+}
+
+static inline bool hvm_hap_supported(void)
+{
+    return false;
+}
+
+static inline bool nhvm_vmcx_hap_enabled(const struct vcpu *v)
+{
+    ASSERT_UNREACHABLE();
+    return false;
+}
+
+
+/* Called by common code */
+static inline int hvm_cpu_up(void)
+{
+    return 0;
+}
+
+static inline void hvm_cpu_down(void) {}
+
+static inline void hvm_flush_guest_tlbs(void) {}
+
+static inline void hvm_invlpg(const struct vcpu *v, unsigned long linear)
+{
+    ASSERT_UNREACHABLE();
+}
+
+/*
+ * Shadow code further cleanup to eliminate some HVM-only paths.  For
+ * now provide the stubs here but assert they will never be reached.
+ */
+static inline void hvm_update_host_cr3(const struct vcpu *v)
+{
+    ASSERT_UNREACHABLE();
+}
+
+static inline void hvm_update_guest_cr3(const struct vcpu *v, bool noflush)
+{
+    ASSERT_UNREACHABLE();
+}
+
+static inline unsigned int hvm_get_cpl(const struct vcpu *v)
+{
+    ASSERT_UNREACHABLE();
+    return -1;
+}
+
+static inline bool hvm_event_pending(const struct vcpu *v)
+{
+    return false;
+}
+
+static inline void hvm_inject_hw_exception(unsigned int vector, int errcode)
+{
+    ASSERT_UNREACHABLE();
+}
+
+#define is_viridian_domain(d) ((void)(d), false)
+#define has_viridian_time_ref_count(d) ((void)(d), false)
+#define hvm_long_mode_active(v) ((void)(v), false)
+#define hvm_get_guest_time(v) ((void)(v), 0)
+
+#define hvm_tsc_scaling_supported false
+#define hap_has_1gb false
+#define hap_has_2mb false
+
+#define hvm_paging_enabled(v) ((void)(v), false)
+#define hvm_wp_enabled(v) ((void)(v), false)
+#define hvm_pcid_enabled(v) ((void)(v), false)
+#define hvm_pae_enabled(v) ((void)(v), false)
+#define hvm_smep_enabled(v) ((void)(v), false)
+#define hvm_smap_enabled(v) ((void)(v), false)
+#define hvm_nx_enabled(v) ((void)(v), false)
+#define hvm_pku_enabled(v) ((void)(v), false)
+
+#define arch_vcpu_block(v) ((void)(v))
+
+#endif  /* CONFIG_HVM */
+
 #endif /* __ASM_X86_HVM_HVM_H__ */
 
 /*
-- 
git-series 0.9.1

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 3/7] x86/mm: put nested p2m code under CONFIG_HVM
  2018-09-13 16:38 [PATCH v4 0/7] Make CONFIG_HVM work Wei Liu
  2018-09-13 16:38 ` [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM Wei Liu
  2018-09-13 16:38 ` [PATCH v4 2/7] x86: provide stubs, declarations and macros in hvm.h Wei Liu
@ 2018-09-13 16:38 ` Wei Liu
  2018-09-14 12:50   ` Jan Beulich
  2018-09-13 16:38 ` [PATCH v4 4/7] x86/mm: put HVM only " Wei Liu
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2018-09-13 16:38 UTC (permalink / raw)
  To: xen-devel; +Cc: George Dunlap, Andrew Cooper, Wei Liu, Jan Beulich

These functions are only useful for nested hvm, which isn't enabled
when CONFIG_HVM is false.

Enclose relevant code and fields in CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v4:
1. Introduce p2m_nestedp2m_init
---
 xen/arch/x86/domain.c        |  4 ++++
 xen/arch/x86/mm/p2m.c        | 25 +++++++++++++++++++++----
 xen/include/asm-x86/domain.h |  2 ++
 xen/include/asm-x86/p2m.h    |  2 ++
 4 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 313ebb3..3da5df6 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1691,7 +1691,9 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
     {
         _update_runstate_area(prev);
         vpmu_switch_from(prev);
+#ifdef CONFIG_HVM
         np2m_schedule(NP2M_SCHEDLE_OUT);
+#endif
     }
 
     if ( is_hvm_domain(prevd) && !list_empty(&prev->arch.hvm.tm_list) )
@@ -1758,7 +1760,9 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
 
         /* Must be done with interrupts enabled */
         vpmu_switch_to(next);
+#ifdef CONFIG_HVM
         np2m_schedule(NP2M_SCHEDLE_IN);
+#endif
     }
 
     /* Ensure that the vcpu has an up-to-date time base. */
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 80b7293..4169084 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -63,23 +63,30 @@ static void p2m_pod_init(struct p2m_domain *p2m)
 #endif
 }
 
+static void p2m_nestedp2m_init(struct p2m_domain *p2m)
+{
+#ifdef CONFIG_HVM
+    INIT_LIST_HEAD(&p2m->np2m_list);
+
+    p2m->np2m_base = P2M_BASE_EADDR;
+    p2m->np2m_generation = 0;
+#endif
+}
+
 /* Init the datastructures for later use by the p2m code */
 static int p2m_initialise(struct domain *d, struct p2m_domain *p2m)
 {
     int ret = 0;
 
     mm_rwlock_init(&p2m->lock);
-    INIT_LIST_HEAD(&p2m->np2m_list);
     INIT_PAGE_LIST_HEAD(&p2m->pages);
 
     p2m->domain = d;
     p2m->default_access = p2m_access_rwx;
     p2m->p2m_class = p2m_host;
 
-    p2m->np2m_base = P2M_BASE_EADDR;
-    p2m->np2m_generation = 0;
-
     p2m_pod_init(p2m);
+    p2m_nestedp2m_init(p2m);
 
     if ( hap_enabled(d) && cpu_has_vmx )
         ret = ept_p2m_init(p2m);
@@ -151,6 +158,7 @@ static void p2m_teardown_hostp2m(struct domain *d)
     }
 }
 
+#ifdef CONFIG_HVM
 static void p2m_teardown_nestedp2m(struct domain *d)
 {
     unsigned int i;
@@ -188,6 +196,7 @@ static int p2m_init_nestedp2m(struct domain *d)
 
     return 0;
 }
+#endif
 
 static void p2m_teardown_altp2m(struct domain *d)
 {
@@ -235,6 +244,7 @@ int p2m_init(struct domain *d)
     if ( rc )
         return rc;
 
+#ifdef CONFIG_HVM
     /* Must initialise nestedp2m unconditionally
      * since nestedhvm_enabled(d) returns false here.
      * (p2m_init runs too early for HVM_PARAM_* options) */
@@ -244,12 +254,15 @@ int p2m_init(struct domain *d)
         p2m_teardown_hostp2m(d);
         return rc;
     }
+#endif
 
     rc = p2m_init_altp2m(d);
     if ( rc )
     {
         p2m_teardown_hostp2m(d);
+#ifdef CONFIG_HVM
         p2m_teardown_nestedp2m(d);
+#endif
     }
 
     return rc;
@@ -701,7 +714,9 @@ void p2m_final_teardown(struct domain *d)
      * we initialise them unconditionally.
      */
     p2m_teardown_altp2m(d);
+#ifdef CONFIG_HVM
     p2m_teardown_nestedp2m(d);
+#endif
 
     /* Iterate over all p2m tables per domain */
     p2m_teardown_hostp2m(d);
@@ -1727,6 +1742,7 @@ void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
         p2m_switch_vcpu_altp2m_by_id(v, idx);
 }
 
+#ifdef CONFIG_HVM
 static struct p2m_domain *
 p2m_getlru_nestedp2m(struct domain *d, struct p2m_domain *p2m)
 {
@@ -1984,6 +2000,7 @@ void np2m_schedule(int dir)
         p2m_unlock(p2m);
     }
 }
+#endif
 
 unsigned long paging_gva_to_gfn(struct vcpu *v,
                                 unsigned long va,
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index 4da4353..b46cfb0 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -333,9 +333,11 @@ struct arch_domain
         void (*tail)(struct vcpu *);
     } *ctxt_switch;
 
+#ifdef CONFIG_HVM
     /* nestedhvm: translate l2 guest physical to host physical */
     struct p2m_domain *nested_p2m[MAX_NESTEDP2M];
     mm_lock_t nested_p2m_lock;
+#endif
 
     /* altp2m: allow multiple copies of host p2m */
     bool_t altp2m_active;
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 3785598..20cf3f1 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -204,6 +204,7 @@ struct p2m_domain {
 
     p2m_class_t       p2m_class; /* host/nested/alternate */
 
+#ifdef CONFIG_HVM
     /* Nested p2ms only: nested p2m base value that this p2m shadows.
      * This can be cleared to P2M_BASE_EADDR under the per-p2m lock but
      * needs both the per-p2m lock and the per-domain nestedp2m lock
@@ -216,6 +217,7 @@ struct p2m_domain {
      * The host p2m hasolds the head of the list and the np2ms are 
      * threaded on in LRU order. */
     struct list_head   np2m_list;
+#endif
 
     /* Host p2m: Log-dirty ranges registered for the domain. */
     struct rangeset   *logdirty_ranges;
-- 
git-series 0.9.1

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 4/7] x86/mm: put HVM only code under CONFIG_HVM
  2018-09-13 16:38 [PATCH v4 0/7] Make CONFIG_HVM work Wei Liu
                   ` (2 preceding siblings ...)
  2018-09-13 16:38 ` [PATCH v4 3/7] x86/mm: put nested p2m code under CONFIG_HVM Wei Liu
@ 2018-09-13 16:38 ` Wei Liu
  2018-09-13 16:50   ` Tamas K Lengyel
  2018-09-13 16:38 ` [PATCH v4 5/7] x86/mm: put paging_update_nestedmode " Wei Liu
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2018-09-13 16:38 UTC (permalink / raw)
  To: xen-devel
  Cc: Tamas K Lengyel, Wei Liu, Razvan Cojocaru, George Dunlap,
	Andrew Cooper, Jan Beulich

Going through the code, HAP, EPT, PoD and ALTP2M depend on HVM code.
Put these components under CONFIG_HVM. This further requires putting
one of the vm event under CONFIG_HVM.

Altp2m requires a bit more attention because its code is embedded in
generic x86 p2m code.

Also make hap_enabled evaluate to false when !CONFIG_HVM. Make sure it
evaluate its parameter to avoid unused variable warnings in its users.

Also sort items in Makefile while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
v4: provide stub for p2m_altp2m_check

Razvan's ack is dropped because of the change. An ack from altp2m
maintainers is required.
---
 xen/arch/x86/mm/Makefile         | 11 ++++++-----
 xen/arch/x86/mm/mem_access.c     | 18 +++++++++++++++++-
 xen/arch/x86/mm/mem_sharing.c    |  2 ++
 xen/arch/x86/mm/p2m.c            | 23 ++++++++++++-----------
 xen/include/asm-x86/altp2m.h     | 13 ++++++++++++-
 xen/include/asm-x86/domain.h     |  2 +-
 xen/include/asm-x86/hvm/domain.h |  4 ++++
 xen/include/asm-x86/p2m.h        |  8 +++++++-
 8 files changed, 61 insertions(+), 20 deletions(-)

diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile
index 3017119..171cc74 100644
--- a/xen/arch/x86/mm/Makefile
+++ b/xen/arch/x86/mm/Makefile
@@ -1,15 +1,16 @@
 subdir-y += shadow
-subdir-y += hap
+subdir-$(CONFIG_HVM) += hap
 
-obj-y += paging.o
-obj-y += p2m.o p2m-pt.o p2m-ept.o p2m-pod.o
-obj-y += altp2m.o
+obj-$(CONFIG_HVM) += altp2m.o
 obj-y += guest_walk_2.o
 obj-y += guest_walk_3.o
 obj-y += guest_walk_4.o
+obj-$(CONFIG_MEM_ACCESS) += mem_access.o
 obj-y += mem_paging.o
 obj-y += mem_sharing.o
-obj-y += mem_access.o
+obj-y += p2m.o p2m-pt.o
+obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o
+obj-y += paging.o
 
 guest_walk_%.o: guest_walk.c Makefile
 	$(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index c980f17..6801841 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -246,7 +246,6 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
     /* Return whether vCPU pause is required (aka. sync event) */
     return (p2ma != p2m_access_n2rwx);
 }
-#endif
 
 int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
                               struct p2m_domain *ap2m, p2m_access_t a,
@@ -291,6 +290,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
      */
     return ap2m->set_entry(ap2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1);
 }
+#endif
 
 static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
                           struct p2m_domain *ap2m, p2m_access_t a,
@@ -298,6 +298,7 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
 {
     int rc = 0;
 
+#ifdef CONFIG_HVM
     if ( ap2m )
     {
         rc = p2m_set_altp2m_mem_access(d, p2m, ap2m, a, gfn);
@@ -306,6 +307,9 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
             rc = 0;
     }
     else
+#else
+    ASSERT(!ap2m);
+#endif
     {
         mfn_t mfn;
         p2m_access_t _a;
@@ -367,6 +371,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, uint32_t nr,
     long rc = 0;
 
     /* altp2m view 0 is treated as the hostp2m */
+#ifdef CONFIG_HVM
     if ( altp2m_idx )
     {
         if ( altp2m_idx >= MAX_ALTP2M ||
@@ -375,6 +380,9 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, uint32_t nr,
 
         ap2m = d->arch.altp2m_p2m[altp2m_idx];
     }
+#else
+    ASSERT(!altp2m_idx);
+#endif
 
     if ( !xenmem_access_to_p2m_access(p2m, access, &a) )
         return -EINVAL;
@@ -422,6 +430,7 @@ long p2m_set_mem_access_multi(struct domain *d,
     long rc = 0;
 
     /* altp2m view 0 is treated as the hostp2m */
+#ifdef CONFIG_HVM
     if ( altp2m_idx )
     {
         if ( altp2m_idx >= MAX_ALTP2M ||
@@ -430,6 +439,9 @@ long p2m_set_mem_access_multi(struct domain *d,
 
         ap2m = d->arch.altp2m_p2m[altp2m_idx];
     }
+#else
+    ASSERT(!altp2m_idx);
+#endif
 
     p2m_lock(p2m);
     if ( ap2m )
@@ -483,12 +495,15 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access)
 
 void arch_p2m_set_access_required(struct domain *d, bool access_required)
 {
+#ifdef CONFIG_HVM
     unsigned int i;
+#endif
 
     ASSERT(atomic_read(&d->pause_count));
 
     p2m_get_hostp2m(d)->access_required = access_required;
 
+#ifdef CONFIG_HVM
     if ( !altp2m_active(d) )
         return;
 
@@ -499,6 +514,7 @@ void arch_p2m_set_access_required(struct domain *d, bool access_required)
         if ( p2m )
             p2m->access_required = access_required;
     }
+#endif
 }
 
 /*
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index d04f9c7..349e6fd 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -802,6 +802,7 @@ static int nominate_page(struct domain *d, gfn_t gfn,
     if ( !p2m_is_sharable(p2mt) )
         goto out;
 
+#ifdef CONFIG_HVM
     /* Check if there are mem_access/remapped altp2m entries for this page */
     if ( altp2m_active(d) )
     {
@@ -829,6 +830,7 @@ static int nominate_page(struct domain *d, gfn_t gfn,
 
         altp2m_list_unlock(d);
     }
+#endif
 
     /* Try to convert the mfn to the sharable type */
     page = mfn_to_page(mfn);
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 4169084..963fde9 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -196,7 +196,6 @@ static int p2m_init_nestedp2m(struct domain *d)
 
     return 0;
 }
-#endif
 
 static void p2m_teardown_altp2m(struct domain *d)
 {
@@ -235,6 +234,7 @@ static int p2m_init_altp2m(struct domain *d)
 
     return 0;
 }
+#endif
 
 int p2m_init(struct domain *d)
 {
@@ -254,16 +254,14 @@ int p2m_init(struct domain *d)
         p2m_teardown_hostp2m(d);
         return rc;
     }
-#endif
 
     rc = p2m_init_altp2m(d);
     if ( rc )
     {
         p2m_teardown_hostp2m(d);
-#ifdef CONFIG_HVM
         p2m_teardown_nestedp2m(d);
-#endif
     }
+#endif
 
     return rc;
 }
@@ -709,12 +707,12 @@ void p2m_teardown(struct p2m_domain *p2m)
 
 void p2m_final_teardown(struct domain *d)
 {
+#ifdef CONFIG_HVM
     /*
      * We must teardown both of them unconditionally because
      * we initialise them unconditionally.
      */
     p2m_teardown_altp2m(d);
-#ifdef CONFIG_HVM
     p2m_teardown_nestedp2m(d);
 #endif
 
@@ -1736,12 +1734,6 @@ void p2m_mem_paging_resume(struct domain *d, vm_event_response_t *rsp)
     }
 }
 
-void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
-{
-    if ( altp2m_active(v->domain) )
-        p2m_switch_vcpu_altp2m_by_id(v, idx);
-}
-
 #ifdef CONFIG_HVM
 static struct p2m_domain *
 p2m_getlru_nestedp2m(struct domain *d, struct p2m_domain *p2m)
@@ -2191,6 +2183,14 @@ int unmap_mmio_regions(struct domain *d,
     return i == nr ? 0 : i ?: ret;
 }
 
+#ifdef CONFIG_HVM
+
+void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
+{
+    if ( altp2m_active(v->domain) )
+        p2m_switch_vcpu_altp2m_by_id(v, idx);
+}
+
 bool_t p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx)
 {
     struct domain *d = v->domain;
@@ -2568,6 +2568,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn,
 
     return ret;
 }
+#endif /* CONFIG_HVM */
 
 /*** Audit ***/
 
diff --git a/xen/include/asm-x86/altp2m.h b/xen/include/asm-x86/altp2m.h
index 64c7618..41fdd82 100644
--- a/xen/include/asm-x86/altp2m.h
+++ b/xen/include/asm-x86/altp2m.h
@@ -18,12 +18,14 @@
 #ifndef __ASM_X86_ALTP2M_H
 #define __ASM_X86_ALTP2M_H
 
+#ifdef CONFIG_HVM
+
 #include <xen/types.h>
 #include <xen/sched.h>         /* for struct vcpu, struct domain */
 #include <asm/hvm/vcpu.h>      /* for vcpu_altp2m */
 
 /* Alternate p2m HVM on/off per domain */
-static inline bool_t altp2m_active(const struct domain *d)
+static inline bool altp2m_active(const struct domain *d)
 {
     return d->arch.altp2m_active;
 }
@@ -37,5 +39,14 @@ static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
 {
     return vcpu_altp2m(v).p2midx;
 }
+#else
+
+static inline bool altp2m_active(const struct domain *d)
+{
+    return false;
+}
+
+uint16_t altp2m_vcpu_idx(const struct vcpu *v);
+#endif
 
 #endif /* __ASM_X86_ALTP2M_H */
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index b46cfb0..cb0721e 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -337,13 +337,13 @@ struct arch_domain
     /* nestedhvm: translate l2 guest physical to host physical */
     struct p2m_domain *nested_p2m[MAX_NESTEDP2M];
     mm_lock_t nested_p2m_lock;
-#endif
 
     /* altp2m: allow multiple copies of host p2m */
     bool_t altp2m_active;
     struct p2m_domain *altp2m_p2m[MAX_ALTP2M];
     mm_lock_t altp2m_list_lock;
     uint64_t *altp2m_eptp;
+#endif
 
     /* NB. protected by d->event_lock and by irq_desc[irq].lock */
     struct radix_tree_root irq_pirq;
diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h
index fa7ebb9..172d27f 100644
--- a/xen/include/asm-x86/hvm/domain.h
+++ b/xen/include/asm-x86/hvm/domain.h
@@ -194,7 +194,11 @@ struct hvm_domain {
     };
 };
 
+#ifdef CONFIG_HVM
 #define hap_enabled(d)  ((d)->arch.hvm.hap_enabled)
+#else
+#define hap_enabled(d)  ({(void)(d); false;})
+#endif
 
 #endif /* __ASM_X86_HVM_DOMAIN_H__ */
 
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 20cf3f1..1db603b 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -231,8 +231,10 @@ struct p2m_domain {
      * host p2m's lock. */
     int                defer_nested_flush;
 
+#ifdef CONFIG_HVM
     /* Alternate p2m: count of vcpu's currently using this p2m. */
     atomic_t           active_vcpus;
+#endif
 
     /* Pages used to construct the p2m */
     struct page_list_head pages;
@@ -823,7 +825,7 @@ void nestedp2m_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
 /*
  * Alternate p2m: shadow p2m tables used for alternate memory views
  */
-
+#ifdef CONFIG_HVM
 /* get current alternate p2m table */
 static inline struct p2m_domain *p2m_get_altp2m(struct vcpu *v)
 {
@@ -870,6 +872,10 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx,
 int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn,
                                 mfn_t mfn, unsigned int page_order,
                                 p2m_type_t p2mt, p2m_access_t p2ma);
+#else
+struct p2m_domain *p2m_get_altp2m(struct vcpu *v);
+static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) {}
+#endif
 
 /*
  * p2m type to IOMMU flags
-- 
git-series 0.9.1

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 5/7] x86/mm: put paging_update_nestedmode under CONFIG_HVM
  2018-09-13 16:38 [PATCH v4 0/7] Make CONFIG_HVM work Wei Liu
                   ` (3 preceding siblings ...)
  2018-09-13 16:38 ` [PATCH v4 4/7] x86/mm: put HVM only " Wei Liu
@ 2018-09-13 16:38 ` Wei Liu
  2018-09-13 16:38 ` [PATCH v4 6/7] xen: connect guest creation with CONFIG_HVM Wei Liu
  2018-09-13 16:38 ` [PATCH v4 7/7] x86: expose CONFIG_HVM Wei Liu
  6 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2018-09-13 16:38 UTC (permalink / raw)
  To: xen-devel; +Cc: George Dunlap, Andrew Cooper, Wei Liu, Jan Beulich

Nested HVM is not enabled when !CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/mm/paging.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index dcee496..7f460bd 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -919,6 +919,7 @@ const struct paging_mode *paging_get_mode(struct vcpu *v)
     return paging_get_nestedmode(v);
 }
 
+#ifdef CONFIG_HVM
 void paging_update_nestedmode(struct vcpu *v)
 {
     ASSERT(nestedhvm_enabled(v->domain));
@@ -930,6 +931,7 @@ void paging_update_nestedmode(struct vcpu *v)
         v->arch.paging.nestedmode = NULL;
     hvm_asid_flush_vcpu(v);
 }
+#endif
 
 void paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
                             l1_pgentry_t *p, l1_pgentry_t new,
-- 
git-series 0.9.1

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 6/7] xen: connect guest creation with CONFIG_HVM
  2018-09-13 16:38 [PATCH v4 0/7] Make CONFIG_HVM work Wei Liu
                   ` (4 preceding siblings ...)
  2018-09-13 16:38 ` [PATCH v4 5/7] x86/mm: put paging_update_nestedmode " Wei Liu
@ 2018-09-13 16:38 ` Wei Liu
  2018-09-14 12:51   ` Jan Beulich
  2018-09-13 16:38 ` [PATCH v4 7/7] x86: expose CONFIG_HVM Wei Liu
  6 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2018-09-13 16:38 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, Jan Beulich

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v4: drop PV part to avoid breaking Arm
---
 xen/common/domain.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index a043812..6dfcea4 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -315,7 +315,14 @@ struct domain *domain_create(domid_t domid,
 
     /* Sort out our idea of is_{pv,hvm}_domain(). */
     if ( config && (config->flags & XEN_DOMCTL_CDF_hvm_guest) )
+    {
+#ifdef CONFIG_HVM
         d->guest_type = guest_type_hvm;
+#else
+        err = -EINVAL;
+        goto fail;
+#endif
+    }
     else
         d->guest_type = guest_type_pv;
 
-- 
git-series 0.9.1

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 7/7] x86: expose CONFIG_HVM
  2018-09-13 16:38 [PATCH v4 0/7] Make CONFIG_HVM work Wei Liu
                   ` (5 preceding siblings ...)
  2018-09-13 16:38 ` [PATCH v4 6/7] xen: connect guest creation with CONFIG_HVM Wei Liu
@ 2018-09-13 16:38 ` Wei Liu
  2018-09-14 12:55   ` Jan Beulich
  6 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2018-09-13 16:38 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Stefano Stabellini, Wei Liu,
	Konrad Rzeszutek Wilk, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, Jan Beulich

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v4: remove a blank line
v3: longer text
v2: use tab to indent

Haven't added a dependency on PV_SHIM_EXCLUSIVE because agreement is
not yet reached.

CC more people for opinions.

Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Juergen Gross <jgross@suse.com>

I don't have an opinion here, that's why I didn't reply to previous
threads.

Maybe

  def_bool y if !PV_SHIM_EXCLUSIVE

is a good compromise?
---
 xen/arch/x86/Kconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index ae1b707..d7a5163 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -60,6 +60,16 @@ config PV_LINEAR_PT
 
 config HVM
 	def_bool y
+	prompt "HVM support"
+	---help---
+	  Interfaces to support HVM guests which require hardware
+	  support like Intel's VT-x or AMD's SVM. Note the hypervisor
+	  doesn't distinguish HVM or PVH guest types. PVH guest type
+	  is only a concept for end users.
+
+	  This option is needed if you want to run HVM or PVH guests.
+
+	  If unsure, say Y.
 
 config SHADOW_PAGING
         bool "Shadow Paging"
-- 
git-series 0.9.1

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 4/7] x86/mm: put HVM only code under CONFIG_HVM
  2018-09-13 16:38 ` [PATCH v4 4/7] x86/mm: put HVM only " Wei Liu
@ 2018-09-13 16:50   ` Tamas K Lengyel
  2018-09-21 15:50     ` Wei Liu
  0 siblings, 1 reply; 19+ messages in thread
From: Tamas K Lengyel @ 2018-09-13 16:50 UTC (permalink / raw)
  To: Wei Liu
  Cc: George Dunlap, Xen-devel, Razvan Cojocaru, Jan Beulich, Andrew Cooper

On Thu, Sep 13, 2018 at 10:38 AM Wei Liu <wei.liu2@citrix.com> wrote:
>
> Going through the code, HAP, EPT, PoD and ALTP2M depend on HVM code.
> Put these components under CONFIG_HVM. This further requires putting
> one of the vm event under CONFIG_HVM.
>
> Altp2m requires a bit more attention because its code is embedded in
> generic x86 p2m code.
>
> Also make hap_enabled evaluate to false when !CONFIG_HVM. Make sure it
> evaluate its parameter to avoid unused variable warnings in its users.
>
> Also sort items in Makefile while at it.
>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> ---
> v4: provide stub for p2m_altp2m_check
>
> Razvan's ack is dropped because of the change. An ack from altp2m
> maintainers is required.
> ---
>  xen/arch/x86/mm/Makefile         | 11 ++++++-----
>  xen/arch/x86/mm/mem_access.c     | 18 +++++++++++++++++-
>  xen/arch/x86/mm/mem_sharing.c    |  2 ++
>  xen/arch/x86/mm/p2m.c            | 23 ++++++++++++-----------
>  xen/include/asm-x86/altp2m.h     | 13 ++++++++++++-
>  xen/include/asm-x86/domain.h     |  2 +-
>  xen/include/asm-x86/hvm/domain.h |  4 ++++
>  xen/include/asm-x86/p2m.h        |  8 +++++++-
>  8 files changed, 61 insertions(+), 20 deletions(-)
>
> diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile
> index 3017119..171cc74 100644
> --- a/xen/arch/x86/mm/Makefile
> +++ b/xen/arch/x86/mm/Makefile
> @@ -1,15 +1,16 @@
>  subdir-y += shadow
> -subdir-y += hap
> +subdir-$(CONFIG_HVM) += hap
>
> -obj-y += paging.o
> -obj-y += p2m.o p2m-pt.o p2m-ept.o p2m-pod.o
> -obj-y += altp2m.o
> +obj-$(CONFIG_HVM) += altp2m.o
>  obj-y += guest_walk_2.o
>  obj-y += guest_walk_3.o
>  obj-y += guest_walk_4.o
> +obj-$(CONFIG_MEM_ACCESS) += mem_access.o
>  obj-y += mem_paging.o
>  obj-y += mem_sharing.o
> -obj-y += mem_access.o
> +obj-y += p2m.o p2m-pt.o
> +obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o
> +obj-y += paging.o
>
>  guest_walk_%.o: guest_walk.c Makefile
>         $(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
> diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
> index c980f17..6801841 100644
> --- a/xen/arch/x86/mm/mem_access.c
> +++ b/xen/arch/x86/mm/mem_access.c
> @@ -246,7 +246,6 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
>      /* Return whether vCPU pause is required (aka. sync event) */
>      return (p2ma != p2m_access_n2rwx);
>  }
> -#endif
>
>  int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
>                                struct p2m_domain *ap2m, p2m_access_t a,
> @@ -291,6 +290,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
>       */
>      return ap2m->set_entry(ap2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1);
>  }
> +#endif
>
>  static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
>                            struct p2m_domain *ap2m, p2m_access_t a,
> @@ -298,6 +298,7 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
>  {
>      int rc = 0;
>
> +#ifdef CONFIG_HVM
>      if ( ap2m )
>      {
>          rc = p2m_set_altp2m_mem_access(d, p2m, ap2m, a, gfn);
> @@ -306,6 +307,9 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
>              rc = 0;
>      }
>      else
> +#else
> +    ASSERT(!ap2m);
> +#endif
>      {
>          mfn_t mfn;
>          p2m_access_t _a;
> @@ -367,6 +371,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, uint32_t nr,
>      long rc = 0;
>
>      /* altp2m view 0 is treated as the hostp2m */
> +#ifdef CONFIG_HVM
>      if ( altp2m_idx )
>      {
>          if ( altp2m_idx >= MAX_ALTP2M ||
> @@ -375,6 +380,9 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, uint32_t nr,
>
>          ap2m = d->arch.altp2m_p2m[altp2m_idx];
>      }
> +#else
> +    ASSERT(!altp2m_idx);
> +#endif
>
>      if ( !xenmem_access_to_p2m_access(p2m, access, &a) )
>          return -EINVAL;
> @@ -422,6 +430,7 @@ long p2m_set_mem_access_multi(struct domain *d,
>      long rc = 0;
>
>      /* altp2m view 0 is treated as the hostp2m */
> +#ifdef CONFIG_HVM
>      if ( altp2m_idx )
>      {
>          if ( altp2m_idx >= MAX_ALTP2M ||
> @@ -430,6 +439,9 @@ long p2m_set_mem_access_multi(struct domain *d,
>
>          ap2m = d->arch.altp2m_p2m[altp2m_idx];
>      }
> +#else
> +    ASSERT(!altp2m_idx);
> +#endif
>
>      p2m_lock(p2m);
>      if ( ap2m )
> @@ -483,12 +495,15 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access)
>
>  void arch_p2m_set_access_required(struct domain *d, bool access_required)
>  {
> +#ifdef CONFIG_HVM
>      unsigned int i;
> +#endif

Perhaps this would look a little nicer with a minor restructure so
that there are no two ifdefs within this function..

>
>      ASSERT(atomic_read(&d->pause_count));
>
>      p2m_get_hostp2m(d)->access_required = access_required;
>
> +#ifdef CONFIG_HVM
>      if ( !altp2m_active(d) )

.. by changing this is into if ( altp2m_active(d) ) and moving the
unsigned int i declaration afterwards. I understand however if you
want to keep this patch mechanical.

>          return;
>
> @@ -499,6 +514,7 @@ void arch_p2m_set_access_required(struct domain *d, bool access_required)
>          if ( p2m )
>              p2m->access_required = access_required;
>      }
> +#endif
>  }

So with or without that change:
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM
  2018-09-13 16:38 ` [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM Wei Liu
@ 2018-09-13 16:56   ` Tamas K Lengyel
  2018-09-14 12:41   ` Jan Beulich
  1 sibling, 0 replies; 19+ messages in thread
From: Tamas K Lengyel @ 2018-09-13 16:56 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, Razvan Cojocaru, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, Jan Beulich, Xen-devel

> diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
> index 4793aac..50d5ebc 100644
> --- a/xen/common/vm_event.c
> +++ b/xen/common/vm_event.c
> @@ -630,8 +630,6 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec,
>          {
>          case XEN_VM_EVENT_ENABLE:
>          {
> -            struct p2m_domain *p2m = p2m_get_hostp2m(d);
> -
>              rc = -EOPNOTSUPP;
>              /* hvm fixme: p2m_is_foreign types need addressing */
>              if ( is_hvm_domain(hardware_domain) )
> @@ -647,10 +645,12 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec,
>              if ( unlikely(need_iommu(d)) )
>                  break;
>
> +#ifdef CONFIG_HVM

Again, please don't put CONFIG_HVM in common code. If p2m->pod is now
conditionally available we will need a p2m wrapper function that is
arch-aware.

>              rc = -EXDEV;
>              /* Disallow paging in a PoD guest */
> -            if ( p2m->pod.entry_count )
> +            if ( p2m_get_hostp2m(d)->pod.entry_count )
>                  break;
> +#endif

Thanks,
Tamas

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM
  2018-09-13 16:38 ` [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM Wei Liu
  2018-09-13 16:56   ` Tamas K Lengyel
@ 2018-09-14 12:41   ` Jan Beulich
  2018-09-21 16:01     ` Wei Liu
  1 sibling, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2018-09-14 12:41 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, Razvan Cojocaru, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, Tamas K Lengyel, xen-devel

>>> On 13.09.18 at 18:38, <wei.liu2@citrix.com> wrote:
> --- a/xen/arch/x86/mm/p2m-pt.c
> +++ b/xen/arch/x86/mm/p2m-pt.c
> @@ -974,7 +974,9 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
>      unsigned long mfn, gfn, m2pfn;
>  
>      ASSERT(p2m_locked_by_me(p2m));
> +#ifdef CONFIG_HVM
>      ASSERT(pod_locked_by_me(p2m));
> +#endif
>  
>      /* Audit part one: walk the domain's p2m table, checking the entries. */
>      if ( pagetable_get_pfn(p2m_get_pagetable(p2m)) != 0 )
> @@ -1105,6 +1107,7 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
>          unmap_domain_page(l4e);
>      }
>  
> +#ifdef CONFIG_HVM
>      if ( entry_count != p2m->pod.entry_count )
>      {
>          printk("%s: refcounted entry count %ld, audit count %lu!\n",
> @@ -1113,6 +1116,7 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
>                 entry_count);
>          BUG();
>      }
> +#endif
>  
>      return pmbad;
>  }

A single #ifdef around the entire function please, with

#else
# define p2m_pt_audit_p2m NULL
#endif

or some such (like making the audit_p2m structure member go away
altogether), as your change to the conditional around audit_p2m()
suppresses the only caller.

> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -49,18 +49,28 @@ boolean_param("hap_2mb", opt_hap_2mb);
>  
>  DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock);
>  
> +static void p2m_pod_init(struct p2m_domain *p2m)
> +{
> +#ifdef CONFIG_HVM
> +    unsigned int i;
> +
> +    mm_lock_init(&p2m->pod.lock);
> +    INIT_PAGE_LIST_HEAD(&p2m->pod.super);
> +    INIT_PAGE_LIST_HEAD(&p2m->pod.single);
> +
> +    for ( i = 0; i < ARRAY_SIZE(p2m->pod.mrp.list); ++i )
> +        p2m->pod.mrp.list[i] = gfn_x(INVALID_GFN);
> +#endif
> +}

I think this really belongs into p2m-pod.c.

Jan



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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 2/7] x86: provide stubs, declarations and macros in hvm.h
  2018-09-13 16:38 ` [PATCH v4 2/7] x86: provide stubs, declarations and macros in hvm.h Wei Liu
@ 2018-09-14 12:44   ` Jan Beulich
  0 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2018-09-14 12:44 UTC (permalink / raw)
  To: Wei Liu; +Cc: Andrew Cooper, xen-devel

>>> On 13.09.18 at 18:38, <wei.liu2@citrix.com> wrote:
> Make sure hvm_enabled evaluate to false then provide necessary things
> to make xen build when !CONFIG_HVM.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

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



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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 3/7] x86/mm: put nested p2m code under CONFIG_HVM
  2018-09-13 16:38 ` [PATCH v4 3/7] x86/mm: put nested p2m code under CONFIG_HVM Wei Liu
@ 2018-09-14 12:50   ` Jan Beulich
  2018-09-21 15:45     ` Wei Liu
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2018-09-14 12:50 UTC (permalink / raw)
  To: Wei Liu; +Cc: George Dunlap, Andrew Cooper, xen-devel

>>> On 13.09.18 at 18:38, <wei.liu2@citrix.com> wrote:
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -1691,7 +1691,9 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
>      {
>          _update_runstate_area(prev);
>          vpmu_switch_from(prev);
> +#ifdef CONFIG_HVM
>          np2m_schedule(NP2M_SCHEDLE_OUT);
> +#endif
>      }
>  
>      if ( is_hvm_domain(prevd) && !list_empty(&prev->arch.hvm.tm_list) )
> @@ -1758,7 +1760,9 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
>  
>          /* Must be done with interrupts enabled */
>          vpmu_switch_to(next);
> +#ifdef CONFIG_HVM
>          np2m_schedule(NP2M_SCHEDLE_IN);
> +#endif
>      }

Instead of these two #ifdef-s a single stub would have been neater imo.

> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -63,23 +63,30 @@ static void p2m_pod_init(struct p2m_domain *p2m)
>  #endif
>  }
>  
> +static void p2m_nestedp2m_init(struct p2m_domain *p2m)
> +{
> +#ifdef CONFIG_HVM
> +    INIT_LIST_HEAD(&p2m->np2m_list);
> +
> +    p2m->np2m_base = P2M_BASE_EADDR;
> +    p2m->np2m_generation = 0;
> +#endif
> +}

Why don't you follow this placement model ...

> @@ -151,6 +158,7 @@ static void p2m_teardown_hostp2m(struct domain *d)
>      }
>  }
>  
> +#ifdef CONFIG_HVM
>  static void p2m_teardown_nestedp2m(struct domain *d)
>  {
>      unsigned int i;
> @@ -188,6 +196,7 @@ static int p2m_init_nestedp2m(struct domain *d)
>  
>      return 0;
>  }
> +#endif

... here avoiding ...

> @@ -244,12 +254,15 @@ int p2m_init(struct domain *d)
>          p2m_teardown_hostp2m(d);
>          return rc;
>      }
> +#endif
>  
>      rc = p2m_init_altp2m(d);
>      if ( rc )
>      {
>          p2m_teardown_hostp2m(d);
> +#ifdef CONFIG_HVM
>          p2m_teardown_nestedp2m(d);
> +#endif
>      }
>  
>      return rc;
> @@ -701,7 +714,9 @@ void p2m_final_teardown(struct domain *d)
>       * we initialise them unconditionally.
>       */
>      p2m_teardown_altp2m(d);
> +#ifdef CONFIG_HVM
>      p2m_teardown_nestedp2m(d);
> +#endif
>  
>      /* Iterate over all p2m tables per domain */
>      p2m_teardown_hostp2m(d);

... two other #ifdef-s?

Anyway, in the interest of forward progress, preferably with the
adjustments made
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan



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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 6/7] xen: connect guest creation with CONFIG_HVM
  2018-09-13 16:38 ` [PATCH v4 6/7] xen: connect guest creation with CONFIG_HVM Wei Liu
@ 2018-09-14 12:51   ` Jan Beulich
  0 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2018-09-14 12:51 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, Konrad Rzeszutek Wilk, George Dunlap,
	Andrew Cooper, Ian Jackson, Tim Deegan, Julien Grall, xen-devel

>>> On 13.09.18 at 18:38, <wei.liu2@citrix.com> wrote:
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

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



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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 7/7] x86: expose CONFIG_HVM
  2018-09-13 16:38 ` [PATCH v4 7/7] x86: expose CONFIG_HVM Wei Liu
@ 2018-09-14 12:55   ` Jan Beulich
  2018-09-21 15:53     ` Wei Liu
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2018-09-14 12:55 UTC (permalink / raw)
  To: Wei Liu
  Cc: Juergen Gross, Stefano Stabellini, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan, xen-devel

>>> On 13.09.18 at 18:38, <wei.liu2@citrix.com> wrote:
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> v4: remove a blank line
> v3: longer text
> v2: use tab to indent
> 
> Haven't added a dependency on PV_SHIM_EXCLUSIVE because agreement is
> not yet reached.
> 
> CC more people for opinions.
> 
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Juergen Gross <jgross@suse.com>
> 
> I don't have an opinion here, that's why I didn't reply to previous
> threads.
> 
> Maybe
> 
>   def_bool y if !PV_SHIM_EXCLUSIVE
> 
> is a good compromise?

Well, that's the minimum I can live with, but I won't ack a patch without
the earlier suggested "depends on". However, not need for "if ..." here,
just using "def_bool !PV_SHIM_EXCLUSIVE" should be quite fine as long
as there's an always visible prompt.

Note also that ordering within the various Kconfig* files may matter
with this approach, at least when processing things sequentially (like
is happening for the "oldconfig" target, for example): The wrong
default would probably be suggested if PV_SHIM_EXCLUSIVE has not
been given a value yet by the time HVM is getting prompted for.

Jan



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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 3/7] x86/mm: put nested p2m code under CONFIG_HVM
  2018-09-14 12:50   ` Jan Beulich
@ 2018-09-21 15:45     ` Wei Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2018-09-21 15:45 UTC (permalink / raw)
  To: Jan Beulich; +Cc: George Dunlap, Andrew Cooper, Wei Liu, xen-devel

On Fri, Sep 14, 2018 at 06:50:06AM -0600, Jan Beulich wrote:
> >>> On 13.09.18 at 18:38, <wei.liu2@citrix.com> wrote:
> > --- a/xen/arch/x86/domain.c
> > +++ b/xen/arch/x86/domain.c
> > @@ -1691,7 +1691,9 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
> >      {
> >          _update_runstate_area(prev);
> >          vpmu_switch_from(prev);
> > +#ifdef CONFIG_HVM
> >          np2m_schedule(NP2M_SCHEDLE_OUT);
> > +#endif
> >      }
> >  
> >      if ( is_hvm_domain(prevd) && !list_empty(&prev->arch.hvm.tm_list) )
> > @@ -1758,7 +1760,9 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
> >  
> >          /* Must be done with interrupts enabled */
> >          vpmu_switch_to(next);
> > +#ifdef CONFIG_HVM
> >          np2m_schedule(NP2M_SCHEDLE_IN);
> > +#endif
> >      }
> 
> Instead of these two #ifdef-s a single stub would have been neater imo.

Done.

> 
> > --- a/xen/arch/x86/mm/p2m.c
> > +++ b/xen/arch/x86/mm/p2m.c
> > @@ -63,23 +63,30 @@ static void p2m_pod_init(struct p2m_domain *p2m)
> >  #endif
> >  }
> >  
> > +static void p2m_nestedp2m_init(struct p2m_domain *p2m)
> > +{
> > +#ifdef CONFIG_HVM
> > +    INIT_LIST_HEAD(&p2m->np2m_list);
> > +
> > +    p2m->np2m_base = P2M_BASE_EADDR;
> > +    p2m->np2m_generation = 0;
> > +#endif
> > +}
> 
> Why don't you follow this placement model ...
> 
> > @@ -151,6 +158,7 @@ static void p2m_teardown_hostp2m(struct domain *d)
> >      }
> >  }
> >  
> > +#ifdef CONFIG_HVM
> >  static void p2m_teardown_nestedp2m(struct domain *d)
> >  {
> >      unsigned int i;
> > @@ -188,6 +196,7 @@ static int p2m_init_nestedp2m(struct domain *d)
> >  
> >      return 0;
> >  }
> > +#endif
> 
> ... here avoiding ...
> 
> > @@ -244,12 +254,15 @@ int p2m_init(struct domain *d)
> >          p2m_teardown_hostp2m(d);
> >          return rc;
> >      }
> > +#endif
> >  
> >      rc = p2m_init_altp2m(d);
> >      if ( rc )
> >      {
> >          p2m_teardown_hostp2m(d);
> > +#ifdef CONFIG_HVM
> >          p2m_teardown_nestedp2m(d);
> > +#endif

This and the later CONFIG_HVM will be expanded in the next patch.

> >      }
> >  
> >      return rc;
> > @@ -701,7 +714,9 @@ void p2m_final_teardown(struct domain *d)
> >       * we initialise them unconditionally.
> >       */
> >      p2m_teardown_altp2m(d);
> > +#ifdef CONFIG_HVM
> >      p2m_teardown_nestedp2m(d);
> > +#endif
> >  
> >      /* Iterate over all p2m tables per domain */
> >      p2m_teardown_hostp2m(d);
> 
> ... two other #ifdef-s?
> 
> Anyway, in the interest of forward progress, preferably with the
> adjustments made
> Acked-by: Jan Beulich <jbeulich@suse.com>

Thanks.

Wei.

> 
> Jan
> 
> 

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 4/7] x86/mm: put HVM only code under CONFIG_HVM
  2018-09-13 16:50   ` Tamas K Lengyel
@ 2018-09-21 15:50     ` Wei Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2018-09-21 15:50 UTC (permalink / raw)
  To: Tamas K Lengyel
  Cc: Wei Liu, Razvan Cojocaru, George Dunlap, Andrew Cooper,
	Jan Beulich, Xen-devel

On Thu, Sep 13, 2018 at 10:50:45AM -0600, Tamas K Lengyel wrote:
> > @@ -483,12 +495,15 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access)
> >
> >  void arch_p2m_set_access_required(struct domain *d, bool access_required)
> >  {
> > +#ifdef CONFIG_HVM
> >      unsigned int i;
> > +#endif
> 
> Perhaps this would look a little nicer with a minor restructure so
> that there are no two ifdefs within this function..
> 
> >
> >      ASSERT(atomic_read(&d->pause_count));
> >
> >      p2m_get_hostp2m(d)->access_required = access_required;
> >
> > +#ifdef CONFIG_HVM
> >      if ( !altp2m_active(d) )
> 
> .. by changing this is into if ( altp2m_active(d) ) and moving the
> unsigned int i declaration afterwards. I understand however if you
> want to keep this patch mechanical.

Done.

> 
> >          return;
> >
> > @@ -499,6 +514,7 @@ void arch_p2m_set_access_required(struct domain *d, bool access_required)
> >          if ( p2m )
> >              p2m->access_required = access_required;
> >      }
> > +#endif
> >  }
> 
> So with or without that change:
> Acked-by: Tamas K Lengyel <tamas@tklengyel.com>

Thanks.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 7/7] x86: expose CONFIG_HVM
  2018-09-14 12:55   ` Jan Beulich
@ 2018-09-21 15:53     ` Wei Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2018-09-21 15:53 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, Stefano Stabellini, Wei Liu,
	Konrad Rzeszutek Wilk, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, xen-devel

On Fri, Sep 14, 2018 at 06:55:17AM -0600, Jan Beulich wrote:
> >>> On 13.09.18 at 18:38, <wei.liu2@citrix.com> wrote:
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > ---
> > v4: remove a blank line
> > v3: longer text
> > v2: use tab to indent
> > 
> > Haven't added a dependency on PV_SHIM_EXCLUSIVE because agreement is
> > not yet reached.
> > 
> > CC more people for opinions.
> > 
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Jan Beulich <jbeulich@suse.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Tim Deegan <tim@xen.org>
> > Cc: Juergen Gross <jgross@suse.com>
> > 
> > I don't have an opinion here, that's why I didn't reply to previous
> > threads.
> > 
> > Maybe
> > 
> >   def_bool y if !PV_SHIM_EXCLUSIVE
> > 
> > is a good compromise?
> 
> Well, that's the minimum I can live with, but I won't ack a patch without
> the earlier suggested "depends on". However, not need for "if ..." here,
> just using "def_bool !PV_SHIM_EXCLUSIVE" should be quite fine as long
> as there's an always visible prompt.
> 
> Note also that ordering within the various Kconfig* files may matter
> with this approach, at least when processing things sequentially (like
> is happening for the "oldconfig" target, for example): The wrong
> default would probably be suggested if PV_SHIM_EXCLUSIVE has not
> been given a value yet by the time HVM is getting prompted for.

I tried to figure out if there is a well defined model for Kconfig
option processing, but found none.

I don't know what else I can do to unblock this. For now I will just
make a small adjustment.

Wei.

> 
> Jan
> 
> 

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM
  2018-09-14 12:41   ` Jan Beulich
@ 2018-09-21 16:01     ` Wei Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2018-09-21 16:01 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, Razvan Cojocaru,
	Konrad Rzeszutek Wilk, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, Julien Grall, Tamas K Lengyel, xen-devel

On Fri, Sep 14, 2018 at 06:41:49AM -0600, Jan Beulich wrote:
> >>> On 13.09.18 at 18:38, <wei.liu2@citrix.com> wrote:
> > --- a/xen/arch/x86/mm/p2m-pt.c
> > +++ b/xen/arch/x86/mm/p2m-pt.c
> > @@ -974,7 +974,9 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
> >      unsigned long mfn, gfn, m2pfn;
> >  
> >      ASSERT(p2m_locked_by_me(p2m));
> > +#ifdef CONFIG_HVM
> >      ASSERT(pod_locked_by_me(p2m));
> > +#endif
> >  
> >      /* Audit part one: walk the domain's p2m table, checking the entries. */
> >      if ( pagetable_get_pfn(p2m_get_pagetable(p2m)) != 0 )
> > @@ -1105,6 +1107,7 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
> >          unmap_domain_page(l4e);
> >      }
> >  
> > +#ifdef CONFIG_HVM
> >      if ( entry_count != p2m->pod.entry_count )
> >      {
> >          printk("%s: refcounted entry count %ld, audit count %lu!\n",
> > @@ -1113,6 +1116,7 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)
> >                 entry_count);
> >          BUG();
> >      }
> > +#endif
> >  
> >      return pmbad;
> >  }
> 
> A single #ifdef around the entire function please, with
> 
> #else
> # define p2m_pt_audit_p2m NULL
> #endif
> 
> or some such (like making the audit_p2m structure member go away
> altogether), as your change to the conditional around audit_p2m()
> suppresses the only caller.

Done.

> 
> > --- a/xen/arch/x86/mm/p2m.c
> > +++ b/xen/arch/x86/mm/p2m.c
> > @@ -49,18 +49,28 @@ boolean_param("hap_2mb", opt_hap_2mb);
> >  
> >  DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock);
> >  
> > +static void p2m_pod_init(struct p2m_domain *p2m)
> > +{
> > +#ifdef CONFIG_HVM
> > +    unsigned int i;
> > +
> > +    mm_lock_init(&p2m->pod.lock);
> > +    INIT_PAGE_LIST_HEAD(&p2m->pod.super);
> > +    INIT_PAGE_LIST_HEAD(&p2m->pod.single);
> > +
> > +    for ( i = 0; i < ARRAY_SIZE(p2m->pod.mrp.list); ++i )
> > +        p2m->pod.mrp.list[i] = gfn_x(INVALID_GFN);
> > +#endif
> > +}
> 
> I think this really belongs into p2m-pod.c.
> 

And done.

Wei.


> Jan
> 
> 

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-09-21 16:01 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-13 16:38 [PATCH v4 0/7] Make CONFIG_HVM work Wei Liu
2018-09-13 16:38 ` [PATCH v4 1/7] x86/p2m/pod: make it build with !CONFIG_HVM Wei Liu
2018-09-13 16:56   ` Tamas K Lengyel
2018-09-14 12:41   ` Jan Beulich
2018-09-21 16:01     ` Wei Liu
2018-09-13 16:38 ` [PATCH v4 2/7] x86: provide stubs, declarations and macros in hvm.h Wei Liu
2018-09-14 12:44   ` Jan Beulich
2018-09-13 16:38 ` [PATCH v4 3/7] x86/mm: put nested p2m code under CONFIG_HVM Wei Liu
2018-09-14 12:50   ` Jan Beulich
2018-09-21 15:45     ` Wei Liu
2018-09-13 16:38 ` [PATCH v4 4/7] x86/mm: put HVM only " Wei Liu
2018-09-13 16:50   ` Tamas K Lengyel
2018-09-21 15:50     ` Wei Liu
2018-09-13 16:38 ` [PATCH v4 5/7] x86/mm: put paging_update_nestedmode " Wei Liu
2018-09-13 16:38 ` [PATCH v4 6/7] xen: connect guest creation with CONFIG_HVM Wei Liu
2018-09-14 12:51   ` Jan Beulich
2018-09-13 16:38 ` [PATCH v4 7/7] x86: expose CONFIG_HVM Wei Liu
2018-09-14 12:55   ` Jan Beulich
2018-09-21 15:53     ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.