From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>,
"Ian Jackson" <iwj@xenproject.org>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Wei Liu" <wl@xen.org>
Subject: [PATCH v2 06/12] page-alloc: make scrub_on_page() static
Date: Thu, 27 May 2021 14:32:40 +0200 [thread overview]
Message-ID: <6f24db03-8c96-3a81-a073-657743e8faee@suse.com> (raw)
In-Reply-To: <8f56a8f4-0482-932f-96a9-c791bebb4610@suse.com>
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>
---
v2: New.
--- a/xen/arch/x86/mm/mem_paging.c
+++ b/xen/arch/x86/mm/mem_paging.c
@@ -316,9 +316,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);
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -136,6 +136,7 @@
#include <xen/numa.h>
#include <xen/nodemask.h>
#include <xen/event.h>
+#include <xen/vm_event.h>
#include <public/sysctl.h>
#include <public/sched.h>
#include <asm/page.h>
@@ -757,6 +758,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
@@ -2431,10 +2447,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
{
@@ -2519,21 +2537,6 @@ static __init int pagealloc_keyhandler_i
__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 dump_heap(unsigned char key)
{
s_time_t now = NOW();
--- a/xen/include/asm-x86/mem_paging.h
+++ b/xen/include/asm-x86/mem_paging.h
@@ -24,12 +24,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__ */
/*
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -498,8 +498,6 @@ static inline unsigned int get_order_fro
return order;
}
-void scrub_one_page(struct page_info *);
-
#ifndef arch_free_heap_page
#define arch_free_heap_page(d, pg) \
page_list_del(pg, page_to_list(d, pg))
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1117,6 +1117,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;
next prev parent reply other threads:[~2021-05-27 12:32 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 12:29 [PATCH v2 00/12] x86: memcpy() / memset() (non-)ERMS flavors plus fallout Jan Beulich
2021-05-27 12:30 ` [PATCH v2 01/12] x86: introduce ioremap_wc() Jan Beulich
2021-05-27 12:48 ` Julien Grall
2021-05-27 13:09 ` Jan Beulich
2021-05-27 13:30 ` Julien Grall
2021-05-27 14:57 ` Jan Beulich
2021-05-27 12:31 ` [PATCH v2 02/12] x86: re-work memset() Jan Beulich
2021-05-27 12:31 ` [PATCH v2 03/12] x86: re-work memcpy() Jan Beulich
2021-05-27 12:31 ` [PATCH v2 04/12] x86: control memset() and memcpy() inlining Jan Beulich
2021-05-27 12:32 ` [PATCH v2 05/12] x86: introduce "hot" and "cold" page clearing functions Jan Beulich
2021-05-27 12:32 ` Jan Beulich [this message]
2021-05-27 12:33 ` [PATCH v2 07/12] mm: allow page scrubbing routine(s) to be arch controlled Jan Beulich
2021-05-27 13:06 ` Julien Grall
2021-05-27 13:58 ` Jan Beulich
2021-06-03 9:39 ` Julien Grall
2021-06-04 13:23 ` Jan Beulich
2021-06-07 18:12 ` Julien Grall
2021-05-27 12:34 ` [PATCH v2 08/12] x86: move .text.kexec Jan Beulich
2022-02-18 13:34 ` Andrew Cooper
2021-05-27 12:34 ` [PATCH v2 09/12] video/vesa: unmap frame buffer when relinquishing console Jan Beulich
2022-02-18 13:36 ` Andrew Cooper
2021-05-27 12:35 ` [PATCH v2 10/12] video/vesa: drop "vesa-mtrr" command line option Jan Beulich
2021-05-27 12:35 ` [PATCH v2 11/12] video/vesa: drop "vesa-remap" " Jan Beulich
2022-02-18 13:35 ` Andrew Cooper
2021-05-27 12:36 ` [PATCH v2 12/12] video/vesa: adjust (not just) command line option handling Jan Beulich
2022-02-17 11:01 ` [PATCH RESEND v2] x86: introduce ioremap_wc() Jan Beulich
2022-02-17 14:47 ` Roger Pau Monné
2022-02-17 15:02 ` Jan Beulich
2022-02-17 15:50 ` Roger Pau Monné
2022-02-17 15:57 ` Jan Beulich
2022-02-18 9:09 ` Roger Pau Monné
2022-02-18 9:23 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6f24db03-8c96-3a81-a073-657743e8faee@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=julien@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).