* [PATCH 0/2] Large page fixes
@ 2009-06-08 13:00 Avi Kivity
2009-06-08 13:00 ` [PATCH 1/2] KVM: Disable large pages on misaligned memory slots Avi Kivity
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Avi Kivity @ 2009-06-08 13:00 UTC (permalink / raw)
To: kvm; +Cc: Marcelo Tosatti
Couple of random large page fixes for review.
Avi Kivity (2):
KVM: Disable large pages on misaligned memory slots
KVM: Prevent overflow in largepages calculation
virt/kvm/kvm_main.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] KVM: Disable large pages on misaligned memory slots
2009-06-08 13:00 [PATCH 0/2] Large page fixes Avi Kivity
@ 2009-06-08 13:00 ` Avi Kivity
2009-06-08 13:00 ` [PATCH 2/2] KVM: Prevent overflow in largepages calculation Avi Kivity
2009-06-08 13:55 ` [PATCH 0/2] Large page fixes Marcelo Tosatti
2 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2009-06-08 13:00 UTC (permalink / raw)
To: kvm; +Cc: Marcelo Tosatti
If a slots guest physical address and host virtual address unequal (mod
large page size), then we would erronously try to back guest large pages
with host large pages. Detect this misalignment and diable large page
support for the trouble slot.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
virt/kvm/kvm_main.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 9c99307..b9ca73c 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1086,7 +1086,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
{
int r;
gfn_t base_gfn;
- unsigned long npages;
+ unsigned long npages, ugfn;
int largepages;
unsigned long i;
struct kvm_memory_slot *memslot;
@@ -1177,6 +1177,14 @@ int __kvm_set_memory_region(struct kvm *kvm,
new.lpage_info[0].write_count = 1;
if ((base_gfn+npages) % KVM_PAGES_PER_HPAGE)
new.lpage_info[largepages-1].write_count = 1;
+ 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
+ */
+ if ((base_gfn ^ ugfn) & (KVM_PAGES_PER_HPAGE - 1))
+ for (i = 0; i < largepages; ++i)
+ new.lpage_info[i].write_count = 1;
}
/* Allocate page dirty bitmap if needed */
--
1.6.0.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: Prevent overflow in largepages calculation
2009-06-08 13:00 [PATCH 0/2] Large page fixes Avi Kivity
2009-06-08 13:00 ` [PATCH 1/2] KVM: Disable large pages on misaligned memory slots Avi Kivity
@ 2009-06-08 13:00 ` Avi Kivity
2009-06-08 13:55 ` [PATCH 0/2] Large page fixes Marcelo Tosatti
2 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2009-06-08 13:00 UTC (permalink / raw)
To: kvm; +Cc: Marcelo Tosatti
If userspace specifies a memory slot that is larger than 8 petabytes, it
could overflow the largepages variable.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
virt/kvm/kvm_main.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index b9ca73c..669eb4a 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1087,8 +1087,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
int r;
gfn_t base_gfn;
unsigned long npages, ugfn;
- int largepages;
- unsigned long i;
+ unsigned long largepages, i;
struct kvm_memory_slot *memslot;
struct kvm_memory_slot old, new;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Large page fixes
2009-06-08 13:00 [PATCH 0/2] Large page fixes Avi Kivity
2009-06-08 13:00 ` [PATCH 1/2] KVM: Disable large pages on misaligned memory slots Avi Kivity
2009-06-08 13:00 ` [PATCH 2/2] KVM: Prevent overflow in largepages calculation Avi Kivity
@ 2009-06-08 13:55 ` Marcelo Tosatti
2009-06-08 14:21 ` Avi Kivity
2 siblings, 1 reply; 5+ messages in thread
From: Marcelo Tosatti @ 2009-06-08 13:55 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Mon, Jun 08, 2009 at 04:is_largepage_backed00:08PM +0300, Avi Kivity wrote:
> Couple of random large page fixes for review.
>
> Avi Kivity (2):
> KVM: Disable large pages on misaligned memory slots
> KVM: Prevent overflow in largepages calculation
>
> virt/kvm/kvm_main.c | 13 ++++++++++---
> 1 files changed, 10 insertions(+), 3 deletions(-)
Looks good, nice catches.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Large page fixes
2009-06-08 13:55 ` [PATCH 0/2] Large page fixes Marcelo Tosatti
@ 2009-06-08 14:21 ` Avi Kivity
0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2009-06-08 14:21 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm
Marcelo Tosatti wrote:
> On Mon, Jun 08, 2009 at 04:is_largepage_backed00:08PM +0300, Avi Kivity wrote:
>
>> Couple of random large page fixes for review.
>>
>> Avi Kivity (2):
>> KVM: Disable large pages on misaligned memory slots
>> KVM: Prevent overflow in largepages calculation
>>
>> virt/kvm/kvm_main.c | 13 ++++++++++---
>> 1 files changed, 10 insertions(+), 3 deletions(-)
>>
>
> Looks good, nice catches.
>
Thanks for the review, I merged those in.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-08 14:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-08 13:00 [PATCH 0/2] Large page fixes Avi Kivity
2009-06-08 13:00 ` [PATCH 1/2] KVM: Disable large pages on misaligned memory slots Avi Kivity
2009-06-08 13:00 ` [PATCH 2/2] KVM: Prevent overflow in largepages calculation Avi Kivity
2009-06-08 13:55 ` [PATCH 0/2] Large page fixes Marcelo Tosatti
2009-06-08 14:21 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox