public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 13/47] KVM: VMX: conditionally disable 2M pages
Date: Wed, 19 Aug 2009 16:02:09 +0300	[thread overview]
Message-ID: <1250686963-8357-14-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1250686963-8357-1-git-send-email-avi@redhat.com>

From: Marcelo Tosatti <mtosatti@redhat.com>

Disable usage of 2M pages if VMX_EPT_2MB_PAGE_BIT (bit 16) is clear
in MSR_IA32_VMX_EPT_VPID_CAP and EPT is enabled.

[avi: s/largepages_disabled/largepages_enabled/ to avoid negative logic]

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/vmx.c       |    3 +++
 include/linux/kvm_host.h |    1 +
 virt/kvm/kvm_main.c      |   14 ++++++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 94c07ad..fc8d49c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1381,6 +1381,9 @@ static __init int hardware_setup(void)
 	if (!cpu_has_vmx_tpr_shadow())
 		kvm_x86_ops->update_cr8_intercept = NULL;
 
+	if (enable_ept && !cpu_has_vmx_ept_2m_page())
+		kvm_disable_largepages();
+
 	return alloc_kvm_area();
 }
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index c6e4d02..6988858 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -224,6 +224,7 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
 				struct kvm_userspace_memory_region *mem,
 				struct kvm_memory_slot old,
 				int user_alloc);
+void kvm_disable_largepages(void);
 void kvm_arch_flush_shadow(struct kvm *kvm);
 gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn);
 struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 777fe53..48d5e69 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -85,6 +85,8 @@ static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
 
 static bool kvm_rebooting;
 
+static bool largepages_enabled = true;
+
 #ifdef KVM_CAP_DEVICE_ASSIGNMENT
 static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head,
 						      int assigned_dev_id)
@@ -1174,9 +1176,11 @@ int __kvm_set_memory_region(struct kvm *kvm,
 		ugfn = new.userspace_addr >> PAGE_SHIFT;
 		/*
 		 * If the gfn and userspace address are not aligned wrt each
-		 * other, disable large page support for this slot
+		 * other, or if explicitly asked to, disable large page
+		 * support for this slot
 		 */
-		if ((base_gfn ^ ugfn) & (KVM_PAGES_PER_HPAGE - 1))
+		if ((base_gfn ^ ugfn) & (KVM_PAGES_PER_HPAGE - 1) ||
+		    !largepages_enabled)
 			for (i = 0; i < largepages; ++i)
 				new.lpage_info[i].write_count = 1;
 	}
@@ -1291,6 +1295,12 @@ out:
 	return r;
 }
 
+void kvm_disable_largepages(void)
+{
+	largepages_enabled = false;
+}
+EXPORT_SYMBOL_GPL(kvm_disable_largepages);
+
 int is_error_page(struct page *page)
 {
 	return page == bad_page;
-- 
1.6.3.3


  parent reply	other threads:[~2009-08-19 13:12 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-19 13:01 [PATCH 00/47] KVM updates for 2.6.32 merge window (2/4) Avi Kivity
2009-08-19 13:01 ` [PATCH 01/47] KVM: Return to userspace on emulation failure Avi Kivity
2009-08-19 13:01 ` [PATCH 02/47] KVM: MMU: introduce is_last_spte helper Avi Kivity
2009-08-19 13:01 ` [PATCH 03/47] KVM: MMU audit: update count_writable_mappings / count_rmaps Avi Kivity
2009-08-19 13:02 ` [PATCH 04/47] KVM: MMU audit: update audit_write_protection Avi Kivity
2009-08-19 13:02 ` [PATCH 05/47] KVM: MMU audit: nontrapping ptes in nonleaf level Avi Kivity
2009-08-19 13:02 ` [PATCH 06/47] KVM: MMU audit: audit_mappings tweaks Avi Kivity
2009-08-19 13:02 ` [PATCH 07/47] KVM: MMU audit: largepage handling Avi Kivity
2009-08-19 13:02 ` [PATCH 08/47] KVM: Move performance counter MSR access interception to generic x86 path Avi Kivity
2009-08-19 13:02 ` [PATCH 09/47] KVM: VMX: more MSR_IA32_VMX_EPT_VPID_CAP capability bits Avi Kivity
2009-08-19 13:02 ` [PATCH 10/47] KVM: MMU: make for_each_shadow_entry aware of largepages Avi Kivity
2009-08-19 13:02 ` [PATCH 11/47] KVM: MMU: add kvm_mmu_get_spte_hierarchy helper Avi Kivity
2009-08-19 13:02 ` [PATCH 12/47] KVM: VMX: EPT misconfiguration handler Avi Kivity
2009-08-19 13:02 ` Avi Kivity [this message]
2009-08-19 13:02 ` [PATCH 14/47] KVM: Replace pending exception by PF if it happens serially Avi Kivity
2009-08-19 13:02 ` [PATCH 15/47] KVM: Optimize searching for highest IRR Avi Kivity
2009-08-19 13:02 ` [PATCH 16/47] KVM: Fix racy event propagation in timer Avi Kivity
2009-08-19 13:02 ` [PATCH 17/47] KVM: Drop useless atomic test from timer function Avi Kivity
2009-08-19 13:02 ` [PATCH 18/47] KVM: VMX: Only reload guest cr2 if different from host cr2 Avi Kivity
2009-08-19 13:02 ` [PATCH 19/47] KVM: SVM: Don't save/restore " Avi Kivity
2009-08-19 13:02 ` [PATCH 20/47] x86: Add definition for IGNNE MSR Avi Kivity
2009-08-19 13:02 ` [PATCH 21/47] KVM: Implement MSRs used by Hyper-V Avi Kivity
2009-08-19 13:02 ` [PATCH 22/47] KVM: SVM: Implement INVLPGA Avi Kivity
2009-08-19 13:02 ` [PATCH 23/47] KVM: SVM: Improve nested interrupt injection Avi Kivity
2009-08-19 13:02 ` [PATCH 24/47] KVM: convert custom marker based tracing to event traces Avi Kivity
2009-08-19 13:02 ` [PATCH 25/47] KVM: Allow emulation of syscalls instructions on #UD Avi Kivity
2009-08-19 13:02 ` [PATCH 26/47] KVM: x86 emulator: Add missing EFLAGS bit definitions Avi Kivity
2009-08-19 13:02 ` [PATCH 27/47] KVM: x86 emulator: Prepare for emulation of syscall instructions Avi Kivity
2009-08-19 13:02 ` [PATCH 28/47] KVM: x86 emulator: add syscall emulation Avi Kivity
2009-08-19 13:02 ` [PATCH 29/47] KVM: x86 emulator: Add sysenter emulation Avi Kivity
2009-08-19 13:02 ` [PATCH 30/47] KVM: x86 emulator: Add sysexit emulation Avi Kivity
2009-08-19 13:02 ` [PATCH 31/47] KVM: s390: Fix memslot initialization for userspace_addr != 0 Avi Kivity
2009-08-19 13:02 ` [PATCH 32/47] hugetlbfs: export vma_kernel_pagsize to modules Avi Kivity
2009-08-19 13:02 ` [PATCH 33/47] KVM: Prepare memslot data structures for multiple hugepage sizes Avi Kivity
2009-08-19 13:02 ` [PATCH 34/47] KVM: x86: missing locking in PIT/IRQCHIP/SET_BSP_CPU ioctl paths Avi Kivity
2009-08-19 13:02 ` [PATCH 35/47] KVM: ignore AMDs HWCR register access to set the FFDIS bit Avi Kivity
2009-08-19 13:02 ` [PATCH 36/47] KVM: ignore reads from AMDs C1E enabled MSR Avi Kivity
2009-08-19 13:02 ` [PATCH 37/47] KVM: introduce module parameter for ignoring unknown MSRs accesses Avi Kivity
2009-08-19 13:02 ` [PATCH 38/47] KVM: powerpc: convert marker probes to event trace Avi Kivity
2009-08-19 13:02 ` [PATCH 39/47] KVM: remove old KVMTRACE support code Avi Kivity
2009-08-19 13:02 ` [PATCH 40/47] KVM: use vcpu_id instead of bsp_vcpu pointer in kvm_vcpu_is_bsp Avi Kivity
2009-08-19 13:02 ` [PATCH 41/47] KVM: document locking for kvm_io_device_ops Avi Kivity
2009-08-19 13:02 ` [PATCH 42/47] KVM: switch coalesced mmio changes to slots_lock Avi Kivity
2009-08-19 13:02 ` [PATCH 43/47] KVM: switch pit creation " Avi Kivity
2009-08-19 13:02 ` [PATCH 44/47] KVM: convert bus " Avi Kivity
2009-08-19 13:02 ` [PATCH 45/47] KVM: remove in_range from io devices Avi Kivity
2009-08-19 13:02 ` [PATCH 46/47] KVM: document lock nesting rule Avi Kivity
2009-08-19 13:02 ` [PATCH 47/47] KVM: fix lock imbalance Avi Kivity

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=1250686963-8357-14-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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