From: Andrew Cooper Subject: [PATCH 4/4] x86/PoD: Command line option to prohibit any PoD operations Date: Fri, 30 Oct 2015 18:33:42 +0000 Message-ID: <1446230022-8349-5-git-send-email-andrew.cooper3@citrix.com> References: <1446230022-8349-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1446230022-8349-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: George Dunlap , Andrew Cooper , Jan Beulich List-Id: xen-devel@lists.xenproject.org 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 --- CC: Jan Beulich CC: George Dunlap --- 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 > `= ` +### pod +> `= ` + +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: | rmid_max: | cat: | cos_max: | cdp: )` 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