コード例 #1
0
ファイル: hypercalls.c プロジェクト: 274914765/C
/* Last of all, we look at what happens first of all.  The very first time the
 * Guest makes a hypercall, we end up here to set things up: */
static void initialize(struct lg_cpu *cpu)
{
    /* You can't do anything until you're initialized.  The Guest knows the
     * rules, so we're unforgiving here. */
    if (cpu->hcall->arg0 != LHCALL_LGUEST_INIT) {
        kill_guest(cpu, "hypercall %li before INIT", cpu->hcall->arg0);
        return;
    }

    if (lguest_arch_init_hypercalls(cpu))
        kill_guest(cpu, "bad guest page %p", cpu->lg->lguest_data);

    /* The Guest tells us where we're not to deliver interrupts by putting
     * the range of addresses into "struct lguest_data". */
    if (get_user(cpu->lg->noirq_start, &cpu->lg->lguest_data->noirq_start)
        || get_user(cpu->lg->noirq_end, &cpu->lg->lguest_data->noirq_end))
        kill_guest(cpu, "bad guest page %p", cpu->lg->lguest_data);

    /* We write the current time into the Guest's data page once so it can
     * set its clock. */
    write_timestamp(cpu);

    /* page_tables.c will also do some setup. */
    page_table_guest_data_init(cpu);

    /* This is the one case where the above accesses might have been the
     * first write to a Guest page.  This may have caused a copy-on-write
     * fault, but the old page might be (read-only) in the Guest
     * pagetable. */
    guest_pagetable_clear_all(cpu);
}
コード例 #2
0
static void initialize(struct lg_cpu *cpu)
{
	if (cpu->hcall->arg0 != LHCALL_LGUEST_INIT) {
		kill_guest(cpu, "hypercall %li before INIT", cpu->hcall->arg0);
		return;
	}

	if (lguest_arch_init_hypercalls(cpu))
		kill_guest(cpu, "bad guest page %p", cpu->lg->lguest_data);

	if (get_user(cpu->lg->noirq_start, &cpu->lg->lguest_data->noirq_start)
	    || get_user(cpu->lg->noirq_end, &cpu->lg->lguest_data->noirq_end))
		kill_guest(cpu, "bad guest page %p", cpu->lg->lguest_data);

	write_timestamp(cpu);

	
	page_table_guest_data_init(cpu);

	guest_pagetable_clear_all(cpu);
}