diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2009-06-11 11:07:44 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-09-10 01:32:56 -0400 |
commit | 54dee9933e8d93589ad63ec3d6be39f1921b0767 (patch) | |
tree | 77aa79604ddfb6f842e582e7b8ce7cdbc54b2060 /virt/kvm | |
parent | 68f89400bc92421d6da22e1ec8e3ec599c3c8244 (diff) |
KVM: VMX: conditionally disable 2M pages
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>
Diffstat (limited to 'virt/kvm')
-rw-r--r-- | virt/kvm/kvm_main.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 777fe533cfe7..48d5e697bf44 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, | |||
85 | 85 | ||
86 | static bool kvm_rebooting; | 86 | static bool kvm_rebooting; |
87 | 87 | ||
88 | static bool largepages_enabled = true; | ||
89 | |||
88 | #ifdef KVM_CAP_DEVICE_ASSIGNMENT | 90 | #ifdef KVM_CAP_DEVICE_ASSIGNMENT |
89 | static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head, | 91 | static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head, |
90 | int assigned_dev_id) | 92 | int assigned_dev_id) |
@@ -1174,9 +1176,11 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
1174 | ugfn = new.userspace_addr >> PAGE_SHIFT; | 1176 | ugfn = new.userspace_addr >> PAGE_SHIFT; |
1175 | /* | 1177 | /* |
1176 | * If the gfn and userspace address are not aligned wrt each | 1178 | * If the gfn and userspace address are not aligned wrt each |
1177 | * other, disable large page support for this slot | 1179 | * other, or if explicitly asked to, disable large page |
1180 | * support for this slot | ||
1178 | */ | 1181 | */ |
1179 | if ((base_gfn ^ ugfn) & (KVM_PAGES_PER_HPAGE - 1)) | 1182 | if ((base_gfn ^ ugfn) & (KVM_PAGES_PER_HPAGE - 1) || |
1183 | !largepages_enabled) | ||
1180 | for (i = 0; i < largepages; ++i) | 1184 | for (i = 0; i < largepages; ++i) |
1181 | new.lpage_info[i].write_count = 1; | 1185 | new.lpage_info[i].write_count = 1; |
1182 | } | 1186 | } |
@@ -1291,6 +1295,12 @@ out: | |||
1291 | return r; | 1295 | return r; |
1292 | } | 1296 | } |
1293 | 1297 | ||
1298 | void kvm_disable_largepages(void) | ||
1299 | { | ||
1300 | largepages_enabled = false; | ||
1301 | } | ||
1302 | EXPORT_SYMBOL_GPL(kvm_disable_largepages); | ||
1303 | |||
1294 | int is_error_page(struct page *page) | 1304 | int is_error_page(struct page *page) |
1295 | { | 1305 | { |
1296 | return page == bad_page; | 1306 | return page == bad_page; |