|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v6 02/43] altp2m: Move altp2m_active to common domain struct
From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
This commit moves altp2m_active from arch_domain on x86 to the common
domain struct. Similarly to nr_altp2m, this is not an arch-specific value.
Moving it to common code allows the common altp2m routines introduced later
in this patch series to operate on altp2m_active without needing an
altp2m_active member on arch_domain for each architecture supporting
altp2m.
This is commit 2/8 of the preparation phase.
This commit is a refactor, and no change in functionality is intended.
Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.
---
xen/arch/x86/hvm/emulate.c | 1 +
xen/arch/x86/hvm/hvm.c | 11 ++++++-----
xen/arch/x86/hvm/monitor.c | 1 +
xen/arch/x86/hvm/vmx/vmx.c | 1 +
xen/arch/x86/include/asm/altp2m.h | 11 -----------
xen/arch/x86/include/asm/domain.h | 2 --
xen/arch/x86/mm/altp2m.c | 1 +
xen/arch/x86/mm/hap/hap.c | 5 +++--
xen/arch/x86/mm/mem_access.c | 1 +
xen/arch/x86/mm/mem_sharing.c | 1 +
xen/arch/x86/mm/p2m-ept.c | 1 +
xen/arch/x86/mm/p2m-pt.c | 1 +
xen/arch/x86/mm/p2m.c | 1 +
xen/common/monitor.c | 1 +
xen/include/asm-generic/altp2m.h | 8 --------
xen/include/xen/altp2m.h | 19 +++++++++++++++++++
xen/include/xen/sched.h | 2 ++
17 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index f3aae158e9f8..9a9b89a232e6 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -9,6 +9,7 @@
* Keir Fraser <keir@xxxxxxx>
*/
+#include <xen/altp2m.h>
#include <xen/init.h>
#include <xen/iocap.h>
#include <xen/ioreq.h>
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 4a81afce02e7..86c12c0d1ef4 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -7,6 +7,7 @@
* Copyright (c) 2008, Citrix Systems, Inc.
*/
+#include <xen/altp2m.h>
#include <xen/console.h>
#include <xen/cpu.h>
#include <xen/domain.h>
@@ -4612,7 +4613,7 @@ static int do_altp2m_op(
if ( (a.cmd != HVMOP_altp2m_get_domain_state) &&
(a.cmd != HVMOP_altp2m_set_domain_state) &&
- !d->arch.altp2m_active )
+ !d->altp2m_active )
{
rc = -EOPNOTSUPP;
goto out;
@@ -4657,11 +4658,11 @@ static int do_altp2m_op(
if ( rc )
break;
- ostate = d->arch.altp2m_active;
- d->arch.altp2m_active = !!a.u.domain_state.state;
+ ostate = d->altp2m_active;
+ d->altp2m_active = !!a.u.domain_state.state;
/* If the alternate p2m state has changed, handle appropriately */
- if ( d->arch.altp2m_active != ostate &&
+ if ( d->altp2m_active != ostate &&
(ostate || !(rc = p2m_init_altp2m_by_id(d, 0))) )
{
for_each_vcpu( d, v )
@@ -4676,7 +4677,7 @@ static int do_altp2m_op(
p2m_flush_altp2m(d);
}
else if ( rc )
- d->arch.altp2m_active = false;
+ d->altp2m_active = false;
domain_unpause_except_self(d);
break;
diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c
index d22a2e464460..84c1c2234ca9 100644
--- a/xen/arch/x86/hvm/monitor.c
+++ b/xen/arch/x86/hvm/monitor.c
@@ -22,6 +22,7 @@
* this program; If not, see <http://www.gnu.org/licenses/>.
*/
+#include <xen/altp2m.h>
#include <xen/vm_event.h>
#include <xen/mem_access.h>
#include <xen/monitor.h>
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 269ca5643346..ff895f7f9437 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4,6 +4,7 @@
* Copyright (c) 2004, Intel Corporation.
*/
+#include <xen/altp2m.h>
#include <xen/domain_page.h>
#include <xen/guest_access.h>
#include <xen/hypercall.h>
diff --git a/xen/arch/x86/include/asm/altp2m.h
b/xen/arch/x86/include/asm/altp2m.h
index 9c1ac3cc2676..ad5ded833a75 100644
--- a/xen/arch/x86/include/asm/altp2m.h
+++ b/xen/arch/x86/include/asm/altp2m.h
@@ -28,12 +28,6 @@ static inline bool altp2m_is_eptp_valid(const struct domain
*d,
mfn_x(INVALID_MFN);
}
-/* Alternate p2m HVM on/off per domain */
-static inline bool altp2m_active(const struct domain *d)
-{
- return d->arch.altp2m_active;
-}
-
static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
{
return vcpu_altp2m(v).p2midx;
@@ -64,11 +58,6 @@ static inline bool altp2m_is_eptp_valid(const struct domain
*d,
return false;
}
-static inline bool altp2m_active(const struct domain *d)
-{
- return false;
-}
-
/* Only declaration is needed. DCE will optimise it out when linking. */
uint16_t altp2m_vcpu_idx(const struct vcpu *v);
void altp2m_vcpu_initialise(struct vcpu *v);
diff --git a/xen/arch/x86/include/asm/domain.h
b/xen/arch/x86/include/asm/domain.h
index 385a6666dafa..0cf0c0d92087 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -368,8 +368,6 @@ struct arch_domain
mm_lock_t nested_p2m_lock;
#ifdef CONFIG_ALTP2M
- /* altp2m: allow multiple copies of host p2m */
- bool altp2m_active;
struct p2m_domain **altp2m_p2m;
mm_lock_t altp2m_list_lock;
uint64_t *altp2m_eptp;
diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c
index 0bc9b9ad2f52..08db8f37c1b1 100644
--- a/xen/arch/x86/mm/altp2m.c
+++ b/xen/arch/x86/mm/altp2m.c
@@ -8,6 +8,7 @@
#include <asm/p2m.h>
#include <asm/altp2m.h>
#include <public/hvm/hvm_op.h>
+#include <xen/altp2m.h>
#include <xen/event.h>
#include <xen/xvmalloc.h>
#include "mm-locks.h"
diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c
index 5ccb80bda5d3..3d563b3bc2d1 100644
--- a/xen/arch/x86/mm/hap/hap.c
+++ b/xen/arch/x86/mm/hap/hap.c
@@ -7,6 +7,7 @@
* Parts of this code are Copyright (c) 2007 by XenSource Inc.
*/
+#include <xen/altp2m.h>
#include <xen/types.h>
#include <xen/mm.h>
#include <xen/trace.h>
@@ -528,7 +529,7 @@ int hap_enable(struct domain *d, u32 mode)
goto out;
}
- d->arch.altp2m_active = false;
+ d->altp2m_active = false;
}
#endif /* CONFIG_ALTP2M */
@@ -595,7 +596,7 @@ void hap_teardown(struct domain *d, bool *preempted)
for_each_vcpu ( d, v )
altp2m_vcpu_disable_ve(v);
- d->arch.altp2m_active = false;
+ d->altp2m_active = false;
FREE_XENHEAP_PAGE(d->arch.altp2m_eptp);
FREE_XENHEAP_PAGE(d->arch.altp2m_visible_eptp);
diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index e55e53f44c78..a9d6b081a523 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -9,6 +9,7 @@
* Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
*/
+#include <xen/altp2m.h>
#include <xen/guest_access.h> /* copy_from_guest() */
#include <xen/mem_access.h>
#include <xen/nospec.h>
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 5c7a0ff30e8b..8319733b1bb6 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -8,6 +8,7 @@
* Copyright (c) 2009 Citrix Systems, Inc. (Grzegorz Milos)
*/
+#include <xen/altp2m.h>
#include <xen/types.h>
#include <xen/domain_page.h>
#include <xen/event.h>
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index dfdbfa0afec8..ed850723f5fd 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -4,6 +4,7 @@
* Copyright (c) 2007, Intel Corporation.
*/
+#include <xen/altp2m.h>
#include <xen/domain_page.h>
#include <xen/sched.h>
#include <public/hvm/dm_op.h>
diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c
index 5a6ce2f8bc2e..17f38aac14d5 100644
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -12,6 +12,7 @@
* Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
*/
+#include <xen/altp2m.h>
#include <xen/vm_event.h>
#include <xen/event.h>
#include <xen/trace.h>
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index fddecdf978ec..41517765c5ec 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -11,6 +11,7 @@
* Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
*/
+#include <xen/altp2m.h>
#include <xen/iommu.h>
#include <xen/mem_access.h>
#include <xen/vm_event.h>
diff --git a/xen/common/monitor.c b/xen/common/monitor.c
index d5c9ff1cbf8c..e758a3fea9f1 100644
--- a/xen/common/monitor.c
+++ b/xen/common/monitor.c
@@ -19,6 +19,7 @@
* License along with this program; If not, see <http://www.gnu.org/licenses/>.
*/
+#include <xen/altp2m.h>
#include <xen/event.h>
#include <xen/monitor.h>
#include <xen/sched.h>
diff --git a/xen/include/asm-generic/altp2m.h b/xen/include/asm-generic/altp2m.h
index 39865a842ab3..ecee6942f4e8 100644
--- a/xen/include/asm-generic/altp2m.h
+++ b/xen/include/asm-generic/altp2m.h
@@ -4,16 +4,8 @@
#include <xen/bug.h>
-struct domain;
struct vcpu;
-/* Alternate p2m on/off per domain */
-static inline bool altp2m_active(const struct domain *d)
-{
- /* Not implemented on GENERIC. */
- return false;
-}
-
/* Alternate p2m VCPU */
static inline unsigned int altp2m_vcpu_idx(const struct vcpu *v)
{
diff --git a/xen/include/xen/altp2m.h b/xen/include/xen/altp2m.h
index 520328fd3fa8..b3b21124dd7e 100644
--- a/xen/include/xen/altp2m.h
+++ b/xen/include/xen/altp2m.h
@@ -2,4 +2,23 @@
#ifndef __XEN_ALTP2M_H__
#define __XEN_ALTP2M_H__
+#include <xen/sched.h>
+
+#ifdef CONFIG_ALTP2M
+
+/* Alternate p2m HVM on/off per domain */
+static inline bool altp2m_active(const struct domain *d)
+{
+ return d->altp2m_active;
+}
+
+#else /* CONFIG_ALTP2M */
+
+static inline bool altp2m_active(const struct domain *d)
+{
+ return false;
+}
+
+#endif /* CONFIG_ALTP2M */
+
#endif /* __XEN_ALTP2M_H__ */
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 212c7d765c3e..458f2f260dd7 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -623,6 +623,8 @@ struct domain
} monitor;
#ifdef CONFIG_ALTP2M
+ /* altp2m: allow multiple copies of host p2m */
+ bool altp2m_active;
unsigned int nr_altp2m; /* Number of altp2m tables. */
#endif
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |