|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/shadow: drop a few uses of mfn_valid()
commit 2497cb428250de36df088b36a47f89a10c115b94
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Jan 12 11:11:47 2023 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jan 12 11:11:47 2023 +0100
x86/shadow: drop a few uses of mfn_valid()
v->arch.paging.shadow.shadow_table[], v->arch.paging.shadow.oos[],
v->arch.paging.shadow.oos_{snapshot[],fixup[].smfn[]} as well as the
hash table are all only ever written with valid MFNs or INVALID_MFN.
Avoid the somewhat expensive mfn_valid() when checking MFNs coming from
these arrays.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/arch/x86/mm/shadow/common.c | 21 ++++++++++-----------
xen/arch/x86/mm/shadow/multi.c | 8 ++++----
xen/arch/x86/mm/shadow/private.h | 4 +++-
3 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index 6f2685d4cf..3f2caf1598 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -171,7 +171,7 @@ static void sh_oos_audit(struct domain *d)
for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ )
{
mfn_t *oos = v->arch.paging.shadow.oos;
- if ( !mfn_valid(oos[idx]) )
+ if ( mfn_eq(oos[idx], INVALID_MFN) )
continue;
expected_idx = mfn_x(oos[idx]) % SHADOW_OOS_PAGES;
@@ -327,8 +327,7 @@ void oos_fixup_add(struct domain *d, mfn_t gmfn,
int i;
for ( i = 0; i < SHADOW_OOS_FIXUPS; i++ )
{
- if ( mfn_valid(oos_fixup[idx].smfn[i])
- && mfn_eq(oos_fixup[idx].smfn[i], smfn)
+ if ( mfn_eq(oos_fixup[idx].smfn[i], smfn)
&& (oos_fixup[idx].off[i] == off) )
return;
}
@@ -461,7 +460,7 @@ static void oos_hash_add(struct vcpu *v, mfn_t gmfn)
idx = mfn_x(gmfn) % SHADOW_OOS_PAGES;
oidx = idx;
- if ( mfn_valid(oos[idx])
+ if ( !mfn_eq(oos[idx], INVALID_MFN)
&& (mfn_x(oos[idx]) % SHADOW_OOS_PAGES) == idx )
{
/* Punt the current occupant into the next slot */
@@ -470,8 +469,8 @@ static void oos_hash_add(struct vcpu *v, mfn_t gmfn)
swap = 1;
idx = (idx + 1) % SHADOW_OOS_PAGES;
}
- if ( mfn_valid(oos[idx]) )
- {
+ if ( !mfn_eq(oos[idx], INVALID_MFN) )
+ {
/* Crush the current occupant. */
_sh_resync(v, oos[idx], &oos_fixup[idx], oos_snapshot[idx]);
perfc_incr(shadow_unsync_evict);
@@ -607,7 +606,7 @@ void sh_resync_all(struct vcpu *v, int skip, int this, int
others)
/* First: resync all of this vcpu's oos pages */
for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ )
- if ( mfn_valid(oos[idx]) )
+ if ( !mfn_eq(oos[idx], INVALID_MFN) )
{
/* Write-protect and sync contents */
_sh_resync(v, oos[idx], &oos_fixup[idx], oos_snapshot[idx]);
@@ -630,7 +629,7 @@ void sh_resync_all(struct vcpu *v, int skip, int this, int
others)
for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ )
{
- if ( !mfn_valid(oos[idx]) )
+ if ( mfn_eq(oos[idx], INVALID_MFN) )
continue;
if ( skip )
@@ -2231,7 +2230,7 @@ void sh_remove_shadows(struct domain *d, mfn_t gmfn, int
fast, int all)
!(pg->shadow_flags & (1 << t)) ) \
break; \
smfn = shadow_hash_lookup(d, mfn_x(gmfn), t); \
- if ( unlikely(!mfn_valid(smfn)) ) \
+ if ( unlikely(mfn_eq(smfn, INVALID_MFN)) ) \
{ \
printk(XENLOG_G_ERR "gmfn %"PRI_mfn" has flags %#x" \
" but no type-%#x shadow\n", \
@@ -2822,7 +2821,7 @@ void shadow_teardown(struct domain *d, bool *preempted)
int i;
mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot;
for ( i = 0; i < SHADOW_OOS_PAGES; i++ )
- if ( mfn_valid(oos_snapshot[i]) )
+ if ( !mfn_eq(oos_snapshot[i], INVALID_MFN) )
{
shadow_free(d, oos_snapshot[i]);
oos_snapshot[i] = INVALID_MFN;
@@ -3005,7 +3004,7 @@ static int shadow_one_bit_disable(struct domain *d, u32
mode)
int i;
mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot;
for ( i = 0; i < SHADOW_OOS_PAGES; i++ )
- if ( mfn_valid(oos_snapshot[i]) )
+ if ( !mfn_eq(oos_snapshot[i], INVALID_MFN) )
{
shadow_free(d, oos_snapshot[i]);
oos_snapshot[i] = INVALID_MFN;
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 5595f42162..e76c1cdb93 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -110,7 +110,7 @@ get_fl1_shadow_status(struct domain *d, gfn_t gfn)
/* Look for FL1 shadows in the hash table */
{
mfn_t smfn = shadow_hash_lookup(d, gfn_x(gfn), SH_type_fl1_shadow);
- ASSERT(!mfn_valid(smfn) || mfn_to_page(smfn)->u.sh.head);
+ ASSERT(mfn_eq(smfn, INVALID_MFN) || mfn_to_page(smfn)->u.sh.head);
return smfn;
}
@@ -2677,7 +2677,7 @@ static int cf_check sh_page_fault(
mfn_t smfn = pagetable_get_mfn(
v->arch.paging.shadow.shadow_table[i]);
- if ( mfn_valid(smfn) && (mfn_x(smfn) != 0) )
+ if ( mfn_x(smfn) )
{
used |= (mfn_to_page(smfn)->v.sh.back == mfn_x(gmfn));
@@ -3821,7 +3821,7 @@ static void cf_check sh_pagetable_dying(paddr_t gpa)
: shadow_hash_lookup(d, mfn_x(gmfn), SH_type_l2_pae_shadow);
}
- if ( mfn_valid(smfn) )
+ if ( !mfn_eq(smfn, INVALID_MFN) )
{
gmfn = _mfn(mfn_to_page(smfn)->v.sh.back);
mfn_to_page(gmfn)->pagetable_dying = true;
@@ -3864,7 +3864,7 @@ static void cf_check sh_pagetable_dying(paddr_t gpa)
smfn = shadow_hash_lookup(d, mfn_x(gmfn), SH_type_l4_64_shadow);
#endif
- if ( mfn_valid(smfn) )
+ if ( !mfn_eq(smfn, INVALID_MFN) )
{
mfn_to_page(gmfn)->pagetable_dying = true;
shadow_unhook_mappings(d, smfn, 1/* user pages only */);
diff --git a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h
index e5329e0d0c..f080baff79 100644
--- a/xen/arch/x86/mm/shadow/private.h
+++ b/xen/arch/x86/mm/shadow/private.h
@@ -764,8 +764,10 @@ get_shadow_status(struct domain *d, mfn_t gmfn, u32
shadow_type)
/* Look for shadows in the hash table */
{
mfn_t smfn = shadow_hash_lookup(d, mfn_x(gmfn), shadow_type);
- ASSERT(!mfn_valid(smfn) || mfn_to_page(smfn)->u.sh.head);
+
+ ASSERT(mfn_eq(smfn, INVALID_MFN) || mfn_to_page(smfn)->u.sh.head);
perfc_incr(shadow_get_shadow_status);
+
return smfn;
}
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |