* [PATCH 1/2] KVM: MMU: Extend kvm_mmu_page->slot_bitmap size
@ 2008-10-16 9:30 Sheng Yang
2008-10-16 9:30 ` [PATCH 2/2] KVM: VMX: Move private memory slot position Sheng Yang
2008-10-19 11:00 ` [PATCH 1/2] KVM: MMU: Extend kvm_mmu_page->slot_bitmap size Avi Kivity
0 siblings, 2 replies; 3+ messages in thread
From: Sheng Yang @ 2008-10-16 9:30 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, Sheng Yang
Otherwise set_bit() for private memory slot(above KVM_MEMORY_SLOTS) would
corrupted memory in 32bit host.
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
arch/x86/kvm/mmu.c | 6 +++---
include/asm-x86/kvm_host.h | 8 +++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 7e70e97..23610b5 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -789,7 +789,7 @@ static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu,
set_page_private(virt_to_page(sp->spt), (unsigned long)sp);
list_add(&sp->link, &vcpu->kvm->arch.active_mmu_pages);
ASSERT(is_empty_shadow_page(sp->spt));
- sp->slot_bitmap = 0;
+ bitmap_zero(sp->slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS);
sp->multimapped = 0;
sp->parent_pte = parent_pte;
--vcpu->kvm->arch.n_free_mmu_pages;
@@ -1364,7 +1364,7 @@ static void page_header_update_slot(struct kvm *kvm, void *pte, gfn_t gfn)
int slot = memslot_id(kvm, gfn_to_memslot(kvm, gfn));
struct kvm_mmu_page *sp = page_header(__pa(pte));
- __set_bit(slot, &sp->slot_bitmap);
+ __set_bit(slot, sp->slot_bitmap);
}
static void mmu_convert_notrap(struct kvm_mmu_page *sp)
@@ -2564,7 +2564,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
int i;
u64 *pt;
- if (!test_bit(slot, &sp->slot_bitmap))
+ if (!test_bit(slot, sp->slot_bitmap))
continue;
pt = sp->spt;
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index 4546535..a38f4a3 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -192,9 +192,11 @@ struct kvm_mmu_page {
u64 *spt;
/* hold the gfn of each spte inside spt */
gfn_t *gfns;
- unsigned long slot_bitmap; /* One bit set per slot which has memory
- * in this shadow page.
- */
+ /*
+ * One bit set per slot which has memory
+ * in this shadow page.
+ */
+ DECLARE_BITMAP(slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS);
int multimapped; /* More than one parent_pte? */
int root_count; /* Currently serving as active root */
bool unsync;
--
1.5.4.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] KVM: VMX: Move private memory slot position
2008-10-16 9:30 [PATCH 1/2] KVM: MMU: Extend kvm_mmu_page->slot_bitmap size Sheng Yang
@ 2008-10-16 9:30 ` Sheng Yang
2008-10-19 11:00 ` [PATCH 1/2] KVM: MMU: Extend kvm_mmu_page->slot_bitmap size Avi Kivity
1 sibling, 0 replies; 3+ messages in thread
From: Sheng Yang @ 2008-10-16 9:30 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, Sheng Yang
PCI device assignment would map guest MMIO spaces as separate slot, so it is
possible that the device has more than 2 MMIO spaces and overwrite current
private memslot.
The patch move private memory slot to the top of userspace visible memory slots.
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
arch/x86/kvm/vmx.c | 2 +-
arch/x86/kvm/vmx.h | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 3d56554..64e2439 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2513,7 +2513,7 @@ static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr)
{
int ret;
struct kvm_userspace_memory_region tss_mem = {
- .slot = 8,
+ .slot = TSS_PRIVATE_MEMSLOT,
.guest_phys_addr = addr,
.memory_size = PAGE_SIZE * 3,
.flags = 0,
diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h
index 3ad61dc..e2341d8 100644
--- a/arch/x86/kvm/vmx.h
+++ b/arch/x86/kvm/vmx.h
@@ -338,8 +338,9 @@ enum vmcs_field {
#define AR_RESERVD_MASK 0xfffe0f00
-#define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT 9
-#define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT 10
+#define TSS_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 0)
+#define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 1)
+#define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 2)
#define VMX_NR_VPIDS (1 << 16)
#define VMX_VPID_EXTENT_SINGLE_CONTEXT 1
--
1.5.4.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] KVM: MMU: Extend kvm_mmu_page->slot_bitmap size
2008-10-16 9:30 [PATCH 1/2] KVM: MMU: Extend kvm_mmu_page->slot_bitmap size Sheng Yang
2008-10-16 9:30 ` [PATCH 2/2] KVM: VMX: Move private memory slot position Sheng Yang
@ 2008-10-19 11:00 ` Avi Kivity
1 sibling, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2008-10-19 11:00 UTC (permalink / raw)
To: Sheng Yang; +Cc: kvm
Sheng Yang wrote:
> Otherwise set_bit() for private memory slot(above KVM_MEMORY_SLOTS) would
> corrupted memory in 32bit host.
>
Applied both patches, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-19 11:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-16 9:30 [PATCH 1/2] KVM: MMU: Extend kvm_mmu_page->slot_bitmap size Sheng Yang
2008-10-16 9:30 ` [PATCH 2/2] KVM: VMX: Move private memory slot position Sheng Yang
2008-10-19 11:00 ` [PATCH 1/2] KVM: MMU: Extend kvm_mmu_page->slot_bitmap size Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox