return rc;
if ( !compat )
- rc = (int)pv_set_gdt(v, c.nat->gdt_frames, c.nat->gdt_ents);
+ rc = pv_set_gdt(v, c.nat->gdt_frames, c.nat->gdt_ents);
else
{
unsigned long gdt_frames[ARRAY_SIZE(v->arch.pv.gdt_frames)];
for ( i = 0; i < nr_gdt_frames; ++i )
gdt_frames[i] = c.cmp->gdt_frames[i];
- rc = (int)pv_set_gdt(v, gdt_frames, c.cmp->gdt_ents);
+ rc = pv_set_gdt(v, gdt_frames, c.cmp->gdt_ents);
}
if ( rc != 0 )
return rc;
}
}
-long pv_set_gdt(struct vcpu *v, unsigned long *frames, unsigned int entries)
+int pv_set_gdt(struct vcpu *v, const unsigned long frames[],
+ unsigned int entries)
{
struct domain *d = v->domain;
l1_pgentry_t *pl1e;
/* Check the pages in the new GDT. */
for ( i = 0; i < nr_frames; i++ )
{
- struct page_info *page;
+ mfn_t mfn = _mfn(frames[i]);
- page = get_page_from_gfn(d, frames[i], NULL, P2M_ALLOC);
- if ( !page )
+ if ( !mfn_valid(mfn) ||
+ !get_page_and_type(mfn_to_page(mfn), d, PGT_seg_desc_page) )
goto fail;
- if ( !get_page_type(page, PGT_seg_desc_page) )
- {
- put_page(page);
- goto fail;
- }
- frames[i] = mfn_x(page_to_mfn(page));
}
/* Tear down the old GDT. */
fail:
while ( i-- > 0 )
- {
put_page_and_type(mfn_to_page(_mfn(frames[i])));
- }
+
return -EINVAL;
}
int pv_ro_page_fault(unsigned long addr, struct cpu_user_regs *regs);
-long pv_set_gdt(struct vcpu *v, unsigned long *frames, unsigned int entries);
+int pv_set_gdt(struct vcpu *v, const unsigned long frames[],
+ unsigned int entries);
void pv_destroy_gdt(struct vcpu *v);
bool pv_map_ldt_shadow_page(unsigned int off);
return 0;
}
-static inline long pv_set_gdt(struct vcpu *v, unsigned long *frames,
- unsigned int entries)
+static inline int pv_set_gdt(struct vcpu *v, const unsigned long frames[],
+ unsigned int entries)
{ ASSERT_UNREACHABLE(); return -EINVAL; }
static inline void pv_destroy_gdt(struct vcpu *v) { ASSERT_UNREACHABLE(); }