qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] helper function and mmu


From: James Greensky
Subject: [Qemu-devel] helper function and mmu
Date: Tue, 24 Jan 2012 11:13:29 -0800

Hello all, I have a quick question that I hope somebody can shed some
light on. Inside of helper functions, can you have a page fault that
must be serviced by the OS? I ask because I cannot see how the cpu
state is restored inside of a helper function. Inside tlb_fill, when
invoked not from a helper but from the translated code, the retaddr is
correct and the cpu_restore_state will be successful. However, when
invoked from a helper function, the retaddr will be that of ldq_kernel
or whatever function calls __ld version of the function in
softmmu_template.h and softmmu_header.h. So surely tb will not be
found and the cpu state will not be restored. Can somebody shed some
more light on this, or should accesses that may cause a page fault be
avoided in helper code.

void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr)
{
    TranslationBlock *tb;
    int ret;
    unsigned long pc;
    CPUX86State *saved_env;

    /* XXX: hack to restore env in all cases, even if not called from
       generated code */
    saved_env = env;
    env = cpu_single_env;

    ret = cpu_x86_handle_mmu_fault(env, addr, is_write, mmu_idx, 1);
    if (ret) {
        if (retaddr) {
            /* now we have a real cpu fault */
            pc = (unsigned long)retaddr;
            tb = tb_find_pc(pc);
            if (tb) {
                /* the PC is inside the translated code. It means that we have
                   a virtual CPU fault */
                cpu_restore_state(tb, env, pc, NULL);
            }
        }
        raise_exception_err(env->exception_index, env->error_code);
    }
    env = saved_env;
}

Thanks, -Jim



reply via email to

[Prev in Thread] Current Thread [Next in Thread]