@@ -304,9 +304,6 @@ static int evict(struct domain *d, gfn_t
ret = p2m_set_entry(p2m, gfn, INVALID_MFN, PAGE_ORDER_4K,
p2m_ram_paged, a);
- /* Clear content before returning the page to Xen */
- scrub_one_page(page);
-
/* Track number of paged gfns */
atomic_inc(&d->paged_pages);
@@ -137,6 +137,7 @@
#include <xen/sections.h>
#include <xen/softirq.h>
#include <xen/spinlock.h>
+#include <xen/vm_event.h>
#include <asm/flushtlb.h>
#include <asm/page.h>
@@ -774,6 +775,21 @@ static void page_list_add_scrub(struct p
#endif
#define SCRUB_BYTE_PATTERN (SCRUB_PATTERN & 0xff)
+static void scrub_one_page(const struct page_info *pg)
+{
+ if ( unlikely(pg->count_info & PGC_broken) )
+ return;
+
+#ifndef NDEBUG
+ /* Avoid callers relying on allocations returning zeroed pages. */
+ unmap_domain_page(memset(__map_domain_page(pg),
+ SCRUB_BYTE_PATTERN, PAGE_SIZE));
+#else
+ /* For a production build, clear_page() is the fastest way to scrub. */
+ clear_domain_page(_mfn(page_to_mfn(pg)));
+#endif
+}
+
static void poison_one_page(struct page_info *pg)
{
#ifdef CONFIG_SCRUB_DEBUG
@@ -2548,10 +2564,12 @@ void free_domheap_pages(struct page_info
/*
* Normally we expect a domain to clear pages before freeing them,
* if it cares about the secrecy of their contents. However, after
- * a domain has died we assume responsibility for erasure. We do
- * scrub regardless if option scrub_domheap is set.
+ * a domain has died or if it has mem-paging enabled we assume
+ * responsibility for erasure. We do scrub regardless if option
+ * scrub_domheap is set.
*/
- scrub = d->is_dying || scrub_debug || opt_scrub_domheap;
+ scrub = d->is_dying || mem_paging_enabled(d) ||
+ scrub_debug || opt_scrub_domheap;
}
else
{
@@ -2635,22 +2653,6 @@ static __init int cf_check pagealloc_key
}
__initcall(pagealloc_keyhandler_init);
-
-void scrub_one_page(struct page_info *pg)
-{
- if ( unlikely(pg->count_info & PGC_broken) )
- return;
-
-#ifndef NDEBUG
- /* Avoid callers relying on allocations returning zeroed pages. */
- unmap_domain_page(memset(__map_domain_page(pg),
- SCRUB_BYTE_PATTERN, PAGE_SIZE));
-#else
- /* For a production build, clear_page() is the fastest way to scrub. */
- clear_domain_page(_mfn(page_to_mfn(pg)));
-#endif
-}
-
static void cf_check dump_heap(unsigned char key)
{
s_time_t now = NOW();
@@ -12,12 +12,6 @@
int mem_paging_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_paging_op_t) arg);
-#ifdef CONFIG_MEM_PAGING
-# define mem_paging_enabled(d) vm_event_check_ring((d)->vm_event_paging)
-#else
-# define mem_paging_enabled(d) false
-#endif
-
#endif /*__ASM_X86_MEM_PAGING_H__ */
/*
@@ -532,8 +532,6 @@ static inline unsigned int get_order_fro
return order;
}
-void scrub_one_page(struct page_info *pg);
-
#ifndef arch_free_heap_page
#define arch_free_heap_page(d, pg) \
page_list_del(pg, page_to_list(d, pg))
@@ -1203,6 +1203,12 @@ static always_inline bool is_iommu_enabl
return evaluate_nospec(d->options & XEN_DOMCTL_CDF_iommu);
}
+#ifdef CONFIG_MEM_PAGING
+# define mem_paging_enabled(d) vm_event_check_ring((d)->vm_event_paging)
+#else
+# define mem_paging_enabled(d) false
+#endif
+
extern bool sched_smt_power_savings;
extern bool sched_disable_smt_switching;
Before starting to alter its properties, restrict the function's visibility. The only external user is mem-paging, which we can accommodate by different means. Also move the function up in its source file, so we won't need to forward-declare it. Constify its parameter at the same time. Signed-off-by: Jan Beulich <jbeulich@suse.com> --- v3: Re-base. v2: New.