Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 45282
b: refs/heads/master
c: 714b93d
h: refs/heads/master
v: v3
  • Loading branch information
Avi Kivity authored and Linus Torvalds committed Jan 6, 2007
1 parent 4b4bbe0 commit d3abfa3
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 38 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f51234c2cd3ab8bed836e09686e27877e1b55f2a
refs/heads/master: 714b93da1a6d97307dfafb9915517879d8a66c0d
16 changes: 15 additions & 1 deletion trunk/drivers/kvm/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ struct kvm_mmu {
u64 *pae_root;
};

#define KVM_NR_MEM_OBJS 20

struct kvm_mmu_memory_cache {
int nobjs;
void *objects[KVM_NR_MEM_OBJS];
};

/*
* We don't want allocation failures within the mmu code, so we preallocate
* enough memory for a single page fault in a cache.
*/
struct kvm_guest_debug {
int enabled;
unsigned long bp[4];
Expand Down Expand Up @@ -239,6 +250,9 @@ struct kvm_vcpu {
struct kvm_mmu_page page_header_buf[KVM_NUM_MMU_PAGES];
struct kvm_mmu mmu;

struct kvm_mmu_memory_cache mmu_pte_chain_cache;
struct kvm_mmu_memory_cache mmu_rmap_desc_cache;

gfn_t last_pt_write_gfn;
int last_pt_write_count;

Expand Down Expand Up @@ -381,7 +395,7 @@ int kvm_mmu_create(struct kvm_vcpu *vcpu);
int kvm_mmu_setup(struct kvm_vcpu *vcpu);

int kvm_mmu_reset_context(struct kvm_vcpu *vcpu);
void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot);
void kvm_mmu_slot_remove_write_access(struct kvm_vcpu *vcpu, int slot);

hpa_t gpa_to_hpa(struct kvm_vcpu *vcpu, gpa_t gpa);
#define HPA_MSB ((sizeof(hpa_t) * 8) - 1)
Expand Down
18 changes: 14 additions & 4 deletions trunk/drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ static int kvm_dev_ioctl_set_memory_region(struct kvm *kvm,
return r;
}

static void do_remove_write_access(struct kvm_vcpu *vcpu, int slot)
{
spin_lock(&vcpu->kvm->lock);
kvm_mmu_slot_remove_write_access(vcpu, slot);
spin_unlock(&vcpu->kvm->lock);
}

/*
* Get (and clear) the dirty memory log for a memory slot.
*/
Expand All @@ -711,6 +718,7 @@ static int kvm_dev_ioctl_get_dirty_log(struct kvm *kvm,
struct kvm_memory_slot *memslot;
int r, i;
int n;
int cleared;
unsigned long any = 0;

spin_lock(&kvm->lock);
Expand Down Expand Up @@ -741,15 +749,17 @@ static int kvm_dev_ioctl_get_dirty_log(struct kvm *kvm,


if (any) {
spin_lock(&kvm->lock);
kvm_mmu_slot_remove_write_access(kvm, log->slot);
spin_unlock(&kvm->lock);
memset(memslot->dirty_bitmap, 0, n);
cleared = 0;
for (i = 0; i < KVM_MAX_VCPUS; ++i) {
struct kvm_vcpu *vcpu = vcpu_load(kvm, i);

if (!vcpu)
continue;
if (!cleared) {
do_remove_write_access(vcpu, log->slot);
memset(memslot->dirty_bitmap, 0, n);
cleared = 1;
}
kvm_arch_ops->tlb_flush(vcpu);
vcpu_put(vcpu);
}
Expand Down
Loading

0 comments on commit d3abfa3

Please sign in to comment.