Skip to contentSkip to conversation

Question about do_interrupt (target-i386/op_helper.c)

Qemu-devel 陳韋任 2 participants 3 messages Jan 19, 2012 – Jan 20, 2012

lore
Share & tools
lore

陳韋任

author
#0 lore raw

Hi all,

I am looking at do_interrupt (target-i386/op_helper.c) and find something
strange. Code sinpt below,

void do_interrupt(CPUState *env1)

{
    CPUState *saved_env;

    saved_env = env;
    env = env1;

    ...
}

In i386-linux-user, cpu_exec (cpu-exec.c) calls do_interrupt like this,

  do_interrupt(env);

My questions are: 1) It seems to me the parameter of do_interrupt (envl) should be the same as env inside do_interrupt (which comes from dyngen-exec.h's #define). Why we need to assign envl to env here? Is it redundant, or I miss something? 2) In target-i386/op_helper.c, some functions use the global env, while others use function parameter env. Is it necessary? Or we can unify how they use env?

Thanks.

Regards,
chenwj

Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
#1 lore raw
Quoted 2 lines · 陳韋任

My questions are: 1) It seems to me the parameter of do_interrupt (envl) should be the same as env inside do_interrupt (which comes from dyngen-exec.h's #define).

In cpu_exec() env is a local variable. In do_interrupt() it is the global variable (held in a specific register via "asm(AREG0)"). The two aren't necessarily the same value, hence the fiddling about.

Quoted 2 lines

In target-i386/op_helper.c, some functions use the global env, while others use function parameter env. Is it necessary? Or we can unify how they use env?

There have been some recent patch series attempting to reduce the use of global env, but it's not a trivial changeover.

-- PMM

author
#2 lore raw
Quoted 3 lines

In cpu_exec() env is a local variable. In do_interrupt() it is the global variable (held in a specific register via "asm(AREG0)"). The two aren't necessarily the same value, hence the fiddling about.

Do you mean we sync env with envl at this point?

Regards,
chenwj

Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj