|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v6 03/43] altp2m: Move altp2m_p2m to common domain struct
From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
Similarly to the previous commit, this commit moves altp2m_p2m to the
common domain struct. The representation of altp2m views as an array of
p2m_domain pointers is the same on x86 and ARM, and it seems that this
would be the case for other architectures as well.
This commit is a refactor, and no change in functionality is intended.
This is commit 3/8 of the preparation phase.
Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.
---
xen/arch/x86/hvm/vmx/vmx.c | 2 +-
xen/arch/x86/include/asm/domain.h | 1 -
xen/arch/x86/include/asm/p2m.h | 4 ++--
xen/arch/x86/mm/altp2m.c | 28 ++++++++++++++--------------
xen/arch/x86/mm/hap/hap.c | 6 +++---
xen/arch/x86/mm/mem_access.c | 8 ++++----
xen/arch/x86/mm/mem_sharing.c | 2 +-
xen/arch/x86/mm/p2m-ept.c | 6 +++---
xen/arch/x86/mm/p2m.c | 8 ++++----
xen/include/xen/sched.h | 1 +
10 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index ff895f7f9437..0909929c00e0 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -5004,7 +5004,7 @@ bool asmlinkage vmx_vmenter_helper(const struct
cpu_user_regs *regs)
if ( currd->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) )
continue;
- ept = &currd->arch.altp2m_p2m[i]->ept;
+ ept = &currd->altp2m_p2m[i]->ept;
if ( cpumask_test_cpu(cpu, ept->invalidate) )
{
cpumask_clear_cpu(cpu, ept->invalidate);
diff --git a/xen/arch/x86/include/asm/domain.h
b/xen/arch/x86/include/asm/domain.h
index 0cf0c0d92087..f8038087e612 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -368,7 +368,6 @@ struct arch_domain
mm_lock_t nested_p2m_lock;
#ifdef CONFIG_ALTP2M
- struct p2m_domain **altp2m_p2m;
mm_lock_t altp2m_list_lock;
uint64_t *altp2m_eptp;
uint64_t *altp2m_visible_eptp;
diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index 3a5a5fd43c2a..ec871717a9e4 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -901,7 +901,7 @@ static inline struct p2m_domain *p2m_get_altp2m(struct vcpu
*v)
BUG_ON(index >= v->domain->nr_altp2m);
- return v->domain->arch.altp2m_p2m[index];
+ return v->domain->altp2m_p2m[index];
}
/* set current alternate p2m table */
@@ -919,7 +919,7 @@ static inline bool p2m_set_altp2m(struct vcpu *v, unsigned
int idx)
atomic_dec(&orig->active_vcpus);
vcpu_altp2m(v).p2midx = idx;
- atomic_inc(&v->domain->arch.altp2m_p2m[idx]->active_vcpus);
+ atomic_inc(&v->domain->altp2m_p2m[idx]->active_vcpus);
return true;
}
diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c
index 08db8f37c1b1..8dd3c0f96be0 100644
--- a/xen/arch/x86/mm/altp2m.c
+++ b/xen/arch/x86/mm/altp2m.c
@@ -130,14 +130,14 @@ int p2m_init_altp2m(struct domain *d)
struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
mm_lock_init(&d->arch.altp2m_list_lock);
- d->arch.altp2m_p2m = xvzalloc_array(struct p2m_domain *, d->nr_altp2m);
+ d->altp2m_p2m = xvzalloc_array(struct p2m_domain *, d->nr_altp2m);
- if ( !d->arch.altp2m_p2m )
+ if ( !d->altp2m_p2m )
return -ENOMEM;
for ( i = 0; i < d->nr_altp2m; i++ )
{
- d->arch.altp2m_p2m[i] = p2m = p2m_init_one(d);
+ d->altp2m_p2m[i] = p2m = p2m_init_one(d);
if ( p2m == NULL )
{
p2m_teardown_altp2m(d);
@@ -158,14 +158,14 @@ void p2m_teardown_altp2m(struct domain *d)
for ( i = 0; i < d->nr_altp2m; i++ )
{
- if ( !d->arch.altp2m_p2m[i] )
+ if ( !d->altp2m_p2m[i] )
continue;
- p2m = d->arch.altp2m_p2m[i];
- d->arch.altp2m_p2m[i] = NULL;
+ p2m = d->altp2m_p2m[i];
+ d->altp2m_p2m[i] = NULL;
p2m_free_one(p2m);
}
- XVFREE(d->arch.altp2m_p2m);
+ XVFREE(d->altp2m_p2m);
}
int altp2m_get_effective_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *mfn,
@@ -325,7 +325,7 @@ static void p2m_reset_altp2m(struct domain *d, unsigned int
idx,
struct p2m_domain *p2m;
ASSERT(idx < d->nr_altp2m);
- p2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
+ p2m = d->altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
p2m_lock(p2m);
@@ -368,7 +368,7 @@ static int p2m_activate_altp2m(struct domain *d, unsigned
int idx,
ASSERT(idx < d->nr_altp2m);
- p2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
+ p2m = d->altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
hostp2m = p2m_get_hostp2m(d);
p2m_lock(p2m);
@@ -468,7 +468,7 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned int
idx)
if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] !=
mfn_x(INVALID_MFN) )
{
- p2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
+ p2m = d->altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
if ( !_atomic_read(p2m->active_vcpus) )
{
@@ -532,7 +532,7 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int
idx,
return rc;
hp2m = p2m_get_hostp2m(d);
- ap2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
+ ap2m = d->altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
p2m_lock(hp2m);
p2m_lock(ap2m);
@@ -596,7 +596,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn,
if ( d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) )
continue;
- p2m = d->arch.altp2m_p2m[i];
+ p2m = d->altp2m_p2m[i];
/* Check for a dropped page that may impact this altp2m */
if ( mfn_eq(mfn, INVALID_MFN) &&
@@ -679,7 +679,7 @@ int p2m_set_suppress_ve_multi(struct domain *d,
return -EINVAL;
p2m = ap2m =
- d->arch.altp2m_p2m[array_index_nospec(sve->view, d->nr_altp2m)];
+ d->altp2m_p2m[array_index_nospec(sve->view, d->nr_altp2m)];
}
p2m_lock(host_p2m);
@@ -746,7 +746,7 @@ int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool
*suppress_ve,
return -EINVAL;
p2m = ap2m =
- d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)];
+ d->altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)];
}
else
p2m = host_p2m;
diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c
index 3d563b3bc2d1..6918a00a2a25 100644
--- a/xen/arch/x86/mm/hap/hap.c
+++ b/xen/arch/x86/mm/hap/hap.c
@@ -524,7 +524,7 @@ int hap_enable(struct domain *d, u32 mode)
for ( i = 0; i < d->nr_altp2m; i++ )
{
- rv = p2m_alloc_table(d->arch.altp2m_p2m[i]);
+ rv = p2m_alloc_table(d->altp2m_p2m[i]);
if ( rv != 0 )
goto out;
}
@@ -548,7 +548,7 @@ void hap_final_teardown(struct domain *d)
#ifdef CONFIG_ALTP2M
if ( hvm_altp2m_supported() )
for ( i = 0; i < d->nr_altp2m; i++ )
- p2m_teardown(d->arch.altp2m_p2m[i], true, NULL);
+ p2m_teardown(d->altp2m_p2m[i], true, NULL);
#endif
/* Destroy nestedp2m's first */
@@ -603,7 +603,7 @@ void hap_teardown(struct domain *d, bool *preempted)
for ( i = 0; i < d->nr_altp2m; i++ )
{
- p2m_teardown(d->arch.altp2m_p2m[i], false, preempted);
+ p2m_teardown(d->altp2m_p2m[i], false, preempted);
if ( preempted && *preempted )
return;
}
diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index a9d6b081a523..e5548e64d8d0 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -319,7 +319,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn,
uint32_t nr,
if ( !altp2m_is_eptp_valid(d, altp2m_idx) )
return -EINVAL;
- ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx,
d->nr_altp2m)];
+ ap2m = d->altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)];
}
#endif
@@ -375,7 +375,7 @@ long p2m_set_mem_access_multi(struct domain *d,
if ( !altp2m_is_eptp_valid(d, altp2m_idx) )
return -EINVAL;
- ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx,
d->nr_altp2m)];
+ ap2m = d->altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)];
}
#endif
@@ -438,7 +438,7 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn,
xenmem_access_t *access,
if ( !altp2m_is_eptp_valid(d, altp2m_idx) )
return -EINVAL;
- p2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)];
+ p2m = d->altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)];
}
#endif
@@ -457,7 +457,7 @@ void arch_p2m_set_access_required(struct domain *d, bool
access_required)
unsigned int i;
for ( i = 0; i < d->nr_altp2m; i++ )
{
- struct p2m_domain *p2m = d->arch.altp2m_p2m[i];
+ struct p2m_domain *p2m = d->altp2m_p2m[i];
if ( p2m )
p2m->access_required = access_required;
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 8319733b1bb6..b7d8fb9ad1aa 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -919,7 +919,7 @@ static int nominate_page(struct domain *d, gfn_t gfn,
for ( i = 0; i < d->nr_altp2m; i++ )
{
- ap2m = d->arch.altp2m_p2m[i];
+ ap2m = d->altp2m_p2m[i];
if ( !ap2m )
continue;
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index ed850723f5fd..ddb4c7606be1 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -1311,7 +1311,7 @@ static void ept_set_ad_sync(struct domain *d, bool value)
if ( d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) )
continue;
- p2m = d->arch.altp2m_p2m[i];
+ p2m = d->altp2m_p2m[i];
p2m_lock(p2m);
p2m->ept.ad = value;
@@ -1579,7 +1579,7 @@ void __init setup_ept_dump(void)
void p2m_init_altp2m_ept(struct domain *d, unsigned int i)
{
struct p2m_domain *p2m =
- d->arch.altp2m_p2m[array_index_nospec(i, d->nr_altp2m)];
+ d->altp2m_p2m[array_index_nospec(i, d->nr_altp2m)];
struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
struct ept_data *ept;
@@ -1603,7 +1603,7 @@ unsigned int p2m_find_altp2m_by_eptp(struct domain *d,
uint64_t eptp)
if ( d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) )
continue;
- p2m = d->arch.altp2m_p2m[i];
+ p2m = d->altp2m_p2m[i];
ept = &p2m->ept;
if ( eptp == ept->eptp )
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 41517765c5ec..5bd426296f20 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -111,7 +111,7 @@ void p2m_change_entry_type_global(struct domain *d,
{
if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) )
{
- struct p2m_domain *altp2m = d->arch.altp2m_p2m[i];
+ struct p2m_domain *altp2m = d->altp2m_p2m[i];
p2m_lock(altp2m);
change_entry_type_global(altp2m, ot, nt);
@@ -157,7 +157,7 @@ bool p2m_memory_type_changed(struct domain *d)
{
if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) )
{
- struct p2m_domain *altp2m = d->arch.altp2m_p2m[i];
+ struct p2m_domain *altp2m = d->altp2m_p2m[i];
p2m_lock(altp2m);
_memory_type_changed(altp2m);
@@ -955,7 +955,7 @@ void p2m_change_type_range(struct domain *d,
{
if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) )
{
- struct p2m_domain *altp2m = d->arch.altp2m_p2m[i];
+ struct p2m_domain *altp2m = d->altp2m_p2m[i];
p2m_lock(altp2m);
change_type_range(altp2m, start, end, ot, nt);
@@ -1031,7 +1031,7 @@ int p2m_finish_type_change(struct domain *d,
{
if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) )
{
- struct p2m_domain *altp2m = d->arch.altp2m_p2m[i];
+ struct p2m_domain *altp2m = d->altp2m_p2m[i];
p2m_lock(altp2m);
rc = finish_type_change(altp2m, first_gfn, max_nr);
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 458f2f260dd7..5d8ba2d2ab19 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -626,6 +626,7 @@ struct domain
/* altp2m: allow multiple copies of host p2m */
bool altp2m_active;
unsigned int nr_altp2m; /* Number of altp2m tables. */
+ struct p2m_domain **altp2m_p2m;
#endif
#ifdef CONFIG_VMTRACE
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |