|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] memory: adjust MEMF_populate_on_demand checking
Pull loop-invariant checks out of the loop. Furthermore reject such
requests for non-HVM domains, rather than treating them as no-op and
signalling success to the caller.
Sadly with this the compiler can't DCE the function call anymore, so
we need a stub now.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
I was tempted to invert the condition of the if() in the latter hunk, for
the remaining one in its present body to then become "else if()". The
larger resulting diff may be disliked, though ...
Handling of other sub-ops will continue to silently ignore
XENMEMF_populate_on_demand.
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -626,12 +626,12 @@ int p2m_remove_page(struct domain *d, gf
int __must_check guest_physmap_add_page(struct domain *d, gfn_t gfn, mfn_t mfn,
unsigned int page_order);
-/* Set a p2m range as populate-on-demand */
-int guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn,
- unsigned int order);
-
#ifdef CONFIG_HVM
+/* Set a p2m range as populate-on-demand */
+int guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn,
+ unsigned int order);
+
/* Enable hardware-assisted log-dirty. */
void p2m_enable_hardware_log_dirty(struct domain *d);
@@ -645,6 +645,14 @@ void p2m_flush_hardware_cached_dirty(str
static inline void p2m_flush_hardware_cached_dirty(struct domain *d) {}
+static inline int guest_physmap_mark_populate_on_demand(struct domain *d,
+ unsigned long gfn,
+ unsigned int order)
+{
+ ASSERT_UNREACHABLE();
+ return -EOPNOTSUPP;
+}
+
#endif
/* Change types across all p2m entries in a domain */
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -239,8 +239,16 @@ static void populate_physmap(struct memo
a->nr_extents-1) )
return;
- if ( a->extent_order > (a->memflags & MEMF_populate_on_demand ? MAX_ORDER :
- max_order(curr_d)) )
+ if ( a->memflags & MEMF_populate_on_demand )
+ {
+ if ( a->extent_order > MAX_ORDER )
+ return;
+
+ /* Disallow populating PoD pages on oneself, or on non-HVM. */
+ if ( d == curr_d || !is_hvm_domain(d) )
+ return;
+ }
+ else if ( a->extent_order > max_order(curr_d) )
return;
if ( unlikely(!d->creation_finished) )
@@ -279,12 +287,7 @@ static void populate_physmap(struct memo
if ( a->memflags & MEMF_populate_on_demand )
{
- /* Disallow populating PoD pages on oneself. */
- if ( d == curr_d )
- goto out;
-
- if ( is_hvm_domain(d) &&
- guest_physmap_mark_populate_on_demand(d, gpfn,
+ if ( guest_physmap_mark_populate_on_demand(d, gpfn,
a->extent_order) < 0 )
goto out;
}
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |