Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 45261
b: refs/heads/master
c: 25c0de2
h: refs/heads/master
i:
  45259: cf6791e
v: v3
  • Loading branch information
Avi Kivity authored and Linus Torvalds committed Jan 6, 2007
1 parent 2e78761 commit f0f790b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 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: aef3d3fe1314f2a130f5ccc7114df20865ba784f
refs/heads/master: 25c0de2cc6c26cb99553c2444936a7951c120c09
24 changes: 11 additions & 13 deletions trunk/drivers/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,13 @@ static int is_empty_shadow_page(hpa_t page_hpa)
return 1;
}

static hpa_t kvm_mmu_alloc_page(struct kvm_vcpu *vcpu, u64 *parent_pte)
static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu,
u64 *parent_pte)
{
struct kvm_mmu_page *page;

if (list_empty(&vcpu->free_pages))
return INVALID_PAGE;
return NULL;

page = list_entry(vcpu->free_pages.next, struct kvm_mmu_page, link);
list_del(&page->link);
Expand All @@ -306,7 +307,7 @@ static hpa_t kvm_mmu_alloc_page(struct kvm_vcpu *vcpu, u64 *parent_pte)
page->slot_bitmap = 0;
page->global = 1;
page->parent_pte = parent_pte;
return page->page_hpa;
return page;
}

static void page_header_update_slot(struct kvm *kvm, void *pte, gpa_t gpa)
Expand Down Expand Up @@ -402,19 +403,16 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, hpa_t p)
}

if (table[index] == 0) {
hpa_t new_table = kvm_mmu_alloc_page(vcpu,
&table[index]);
struct kvm_mmu_page *new_table;

if (!VALID_PAGE(new_table)) {
new_table = kvm_mmu_alloc_page(vcpu, &table[index]);
if (!new_table) {
pgprintk("nonpaging_map: ENOMEM\n");
return -ENOMEM;
}

if (level == PT32E_ROOT_LEVEL)
table[index] = new_table | PT_PRESENT_MASK;
else
table[index] = new_table | PT_PRESENT_MASK |
PT_WRITABLE_MASK | PT_USER_MASK;
table[index] = new_table->page_hpa | PT_PRESENT_MASK
| PT_WRITABLE_MASK | PT_USER_MASK;
}
table_addr = table[index] & PT64_BASE_ADDR_MASK;
}
Expand Down Expand Up @@ -454,7 +452,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
hpa_t root = vcpu->mmu.root_hpa;

ASSERT(!VALID_PAGE(root));
root = kvm_mmu_alloc_page(vcpu, NULL);
root = kvm_mmu_alloc_page(vcpu, NULL)->page_hpa;
vcpu->mmu.root_hpa = root;
return;
}
Expand All @@ -463,7 +461,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
hpa_t root = vcpu->mmu.pae_root[i];

ASSERT(!VALID_PAGE(root));
root = kvm_mmu_alloc_page(vcpu, NULL);
root = kvm_mmu_alloc_page(vcpu, NULL)->page_hpa;
vcpu->mmu.pae_root[i] = root | PT_PRESENT_MASK;
}
vcpu->mmu.root_hpa = __pa(vcpu->mmu.pae_root);
Expand Down
6 changes: 4 additions & 2 deletions trunk/drivers/kvm/paging_tmpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
for (; ; level--) {
u32 index = SHADOW_PT_INDEX(addr, level);
u64 *shadow_ent = ((u64 *)__va(shadow_addr)) + index;
struct kvm_mmu_page *shadow_page;
u64 shadow_pte;

if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) {
Expand All @@ -204,9 +205,10 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
return shadow_ent;
}

shadow_addr = kvm_mmu_alloc_page(vcpu, shadow_ent);
if (!VALID_PAGE(shadow_addr))
shadow_page = kvm_mmu_alloc_page(vcpu, shadow_ent);
if (!shadow_page)
return ERR_PTR(-ENOMEM);
shadow_addr = shadow_page->page_hpa;
shadow_pte = shadow_addr | PT_PRESENT_MASK | PT_ACCESSED_MASK
| PT_WRITABLE_MASK | PT_USER_MASK;
*shadow_ent = shadow_pte;
Expand Down

0 comments on commit f0f790b

Please sign in to comment.