Skip to content

Commit

Permalink
exit/idt-shadow: allocate current_idt on the stack
Browse files Browse the repository at this point in the history
We have 6 pages of stack space to use, no need to exhaust NonPagedPool.
  • Loading branch information
asamy committed May 25, 2017
1 parent 67aecc6 commit c956379
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2084,17 +2084,11 @@ static inline void vcpu_sync_idt(struct vcpu *vcpu, struct gdtr *idt)
* entries that we set, by simply just discarding them.
*/
size_t entries = min((size_t)idt->limit, (PAGE_SIZE - 1)) / sizeof(struct kidt_entry64);
struct kidt_entry64 *current_idt;
struct kidt_entry64 current_idt[256];
struct kidt_entry64 *shadow = (struct kidt_entry64 *)vcpu->idt.base;

current_idt = mm_alloc_page();
if (!current_idt)
return;

if (!ksm_read_virt(vcpu, idt->base, (u8 *)current_idt, idt->limit)) {
mm_free_pool(current_idt, PAGE_SIZE);
if (!ksm_read_virt(vcpu, idt->base, (u8 *)current_idt, idt->limit))
return vcpu_inject_pf(vcpu, idt->base, PGF_PRESENT);
}

KSM_DEBUG("Loading new IDT (new size: %d old size: %d) Copying %d entries\n",
idt->limit, vcpu->idt.limit, (int)entries);
Expand All @@ -2105,7 +2099,6 @@ static inline void vcpu_sync_idt(struct vcpu *vcpu, struct gdtr *idt)
if (!idte_present(&vcpu->shadow_idt[n]))
memcpy(&shadow[n], &current_idt[n], sizeof(*shadow));
vcpu_flush_idt(vcpu);
mm_free_page(current_idt);
}

static bool vcpu_handle_gdt_idt_access(struct vcpu *vcpu)
Expand Down

0 comments on commit c956379

Please sign in to comment.