All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 4/4] x86/PoD: Command line option to prohibit any PoD operations
Date: Fri, 30 Oct 2015 18:33:42 +0000	[thread overview]
Message-ID: <1446230022-8349-5-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1446230022-8349-1-git-send-email-andrew.cooper3@citrix.com>

PoD is only needed to cover a corner case with memory overcommit
(rebooting a ballooned down VM with insufficient host RAM available).

Its use comes with a performance hit, and inoperability with other
technologies such as PCI Passthrough.

Offer a command line option for administrators who want to be certain
that PoD is not in use for their VMs.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
---
 docs/misc/xen-command-line.markdown | 8 ++++++++
 xen/arch/x86/hvm/hvm.c              | 3 +++
 xen/arch/x86/mm.c                   | 6 ++++++
 xen/common/memory.c                 | 4 ++++
 xen/include/asm-x86/hvm/hvm.h       | 2 ++
 5 files changed, 23 insertions(+)

diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown
index 416e559..aaf8a4f 100644
--- a/docs/misc/xen-command-line.markdown
+++ b/docs/misc/xen-command-line.markdown
@@ -1173,6 +1173,14 @@ This option can be specified more than once (up to 8 times at present).
 ### ple\_window
 > `= <integer>`
 
+### pod
+> `= <boolean>`
+
+Default: `true`
+
+Permit or deny the use of Populate on Demand with x86 HVM guests.  If
+disabled, attempts to create VMs with `memory < maxmem` will fail.
+
 ### psr (Intel)
 > `= List of ( cmt:<boolean> | rmid_max:<integer> | cat:<boolean> | cos_max:<integer> | cdp:<boolean> )`
 
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 21f42a7..cf895a7 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -92,6 +92,9 @@ unsigned long __section(".bss.page_aligned")
 static bool_t __initdata opt_hap_enabled = 1;
 boolean_param("hap", opt_hap_enabled);
 
+bool_t opt_pod_enabled = 1;
+boolean_param("pod", opt_pod_enabled);
+
 #ifndef opt_hvm_fep
 bool_t opt_hvm_fep;
 boolean_param("hvm_fep", opt_hvm_fep);
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 92df36f..90270ba 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4929,6 +4929,12 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 
         if ( cmd == XENMEM_set_pod_target )
         {
+            if ( unlikely(!opt_pod_enabled) )
+            {
+                rc = -EOPNOTSUPP;
+                goto pod_target_out_unlock;
+            }
+
             if ( target.target_pages > d->max_pages )
             {
                 rc = -EINVAL;
diff --git a/xen/common/memory.c b/xen/common/memory.c
index a3bffb7..f5ed66e 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -818,6 +818,10 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( unlikely(start_extent >= reservation.nr_extents) )
             return start_extent;
 
+        if ( unlikely(!opt_pod_enabled) &&
+             (reservation.mem_flags & XENMEMF_populate_on_demand) )
+            return start_extent;
+
         d = rcu_lock_domain_by_any_id(reservation.domid);
         if ( d == NULL )
             return start_extent;
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index 0cf7da1..0341ba6 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -555,6 +555,8 @@ extern bool_t opt_hvm_fep;
 #define opt_hvm_fep 0
 #endif
 
+extern bool_t opt_pod_enabled;
+
 /* updates the current hardware p2m */
 void altp2m_vcpu_update_p2m(struct vcpu *v);
 
-- 
2.1.4

  parent reply	other threads:[~2015-10-30 18:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 18:33 [PATCH 0/4] Futher work after XSA-150 Andrew Cooper
2015-10-30 18:33 ` [PATCH 1/4] x86/PoD: Make p2m_pod_empty_cache() restartable Andrew Cooper
2015-11-02 12:17   ` George Dunlap
2015-10-30 18:33 ` [PATCH 2/4] x86/PoD: Identify when a domain has already been killed from PoD exhaustion Andrew Cooper
2015-11-02 14:07   ` George Dunlap
2015-11-02 14:32     ` Andrew Cooper
2015-11-23 14:50       ` Jan Beulich
2015-11-24 16:51       ` George Dunlap
2015-10-30 18:33 ` [PATCH 3/4] x86/mm: Return -ESRCH for an invalid foreign domid Andrew Cooper
2015-11-02 14:10   ` George Dunlap
2015-10-30 18:33 ` Andrew Cooper [this message]
2015-11-02 13:53   ` [PATCH 4/4] x86/PoD: Command line option to prohibit any PoD operations Jan Beulich
2015-11-02 14:32     ` Ian Campbell
2015-11-02 14:37       ` Andrew Cooper
2015-11-02 14:38       ` Jan Beulich
2015-11-02 15:19   ` George Dunlap

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=1446230022-8349-5-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.