From: Marcelo Tosatti <mtosatti@redhat.com>
To: avi@redhat.com
Cc: kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 5/5] KVM: VMX: conditionally disable 2M pages
Date: Thu, 11 Jun 2009 11:02:29 -0300 [thread overview]
Message-ID: <20090611140417.013188677@localhost.localdomain> (raw)
In-Reply-To: <4A307819.6010503@redhat.com>
[-- Attachment #1: disable-2m-pages-vmx --]
[-- Type: text/plain, Size: 2333 bytes --]
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.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm/arch/x86/kvm/vmx.c
===================================================================
--- kvm.orig/arch/x86/kvm/vmx.c
+++ kvm/arch/x86/kvm/vmx.c
@@ -1393,6 +1393,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();
}
Index: kvm/include/linux/kvm_host.h
===================================================================
--- kvm.orig/include/linux/kvm_host.h
+++ kvm/include/linux/kvm_host.h
@@ -219,6 +219,7 @@ int kvm_arch_set_memory_region(struct kv
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);
Index: kvm/virt/kvm/kvm_main.c
===================================================================
--- kvm.orig/virt/kvm/kvm_main.c
+++ kvm/virt/kvm/kvm_main.c
@@ -85,6 +85,8 @@ static long kvm_vcpu_ioctl(struct file *
static bool kvm_rebooting;
+static bool largepages_disabled = false;
+
#ifdef KVM_CAP_DEVICE_ASSIGNMENT
static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head,
int assigned_dev_id)
@@ -1171,9 +1173,11 @@ int __kvm_set_memory_region(struct 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_disabled)
for (i = 0; i < largepages; ++i)
new.lpage_info[i].write_count = 1;
}
@@ -1286,6 +1290,12 @@ out:
return r;
}
+void kvm_disable_largepages(void)
+{
+ largepages_disabled = true;
+}
+EXPORT_SYMBOL_GPL(kvm_disable_largepages);
+
int is_error_page(struct page *page)
{
return page == bad_page;
--
next prev parent reply other threads:[~2009-06-11 14:05 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-09 21:30 [patch 0/5] VMX EPT misconfigurtion handler Marcelo Tosatti
2009-06-09 21:30 ` [patch 1/5] KVM: VMX: more MSR_IA32_VMX_EPT_VPID_CAP capability bits Marcelo Tosatti
2009-06-09 21:30 ` [patch 2/5] KVM: MMU: make for_each_shadow_entry aware of largepages Marcelo Tosatti
2009-06-10 9:15 ` Avi Kivity
2009-06-10 9:21 ` Avi Kivity
2009-06-11 12:38 ` Marcelo Tosatti
2009-06-11 14:17 ` Avi Kivity
2009-06-09 21:30 ` [patch 3/5] KVM: MMU: add kvm_mmu_shadow_walk helper Marcelo Tosatti
2009-06-10 9:17 ` Avi Kivity
2009-06-10 12:14 ` Marcelo Tosatti
2009-06-10 12:23 ` Avi Kivity
2009-06-10 13:17 ` Marcelo Tosatti
2009-06-10 15:24 ` Avi Kivity
2009-06-11 3:20 ` Avi Kivity
2009-06-11 14:02 ` [patch 0/5] VMX EPT misconfiguration handler v2 Marcelo Tosatti
2009-06-11 14:02 ` [patch 1/5] KVM: VMX: more MSR_IA32_VMX_EPT_VPID_CAP capability bits Marcelo Tosatti
2009-06-11 14:02 ` [patch 2/5] KVM: MMU: make for_each_shadow_entry aware of largepages Marcelo Tosatti
2009-06-11 14:02 ` [patch 3/5] KVM: MMU: add kvm_mmu_get_spte_hierarchy helper Marcelo Tosatti
2009-06-11 14:31 ` Avi Kivity
2009-06-11 15:07 ` [patch 0/5] VMX EPT misconfiguration handler v3 Marcelo Tosatti
2009-06-14 9:54 ` Avi Kivity
2009-06-11 15:07 ` [patch 1/5] KVM: VMX: more MSR_IA32_VMX_EPT_VPID_CAP capability bits Marcelo Tosatti
2009-06-11 15:07 ` [patch 2/5] KVM: MMU: make for_each_shadow_entry aware of largepages Marcelo Tosatti
2009-06-11 15:07 ` [patch 3/5] KVM: MMU: add kvm_mmu_get_spte_hierarchy helper Marcelo Tosatti
2009-06-11 15:07 ` [patch 4/5] KVM: VMX: EPT misconfiguration handler Marcelo Tosatti
2009-06-11 15:07 ` [patch 5/5] KVM: VMX: conditionally disable 2M pages Marcelo Tosatti
2009-06-11 14:02 ` [patch 4/5] KVM: VMX: EPT misconfiguration handler Marcelo Tosatti
2009-06-11 14:02 ` Marcelo Tosatti [this message]
2009-06-09 21:30 ` Marcelo Tosatti
2009-06-09 21:30 ` [patch 5/5] KVM: VMX: conditionally disable 2M pages Marcelo Tosatti
2009-06-10 9:18 ` Avi Kivity
2009-06-10 9:13 ` [patch 0/5] VMX EPT misconfigurtion handler Yang, Sheng
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=20090611140417.013188677@localhost.localdomain \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@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 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.