> > I suspect the best solution is to backtrack (remove the generated ops) > > after decoding the insn if we discover we've passed a page boundary. The > > ld*_code routines can simply return garbage (e.g. zero) if the read is > > not on the first page. > > The "incorrect" returned value may be target specific to be sure it's > always an invalid opcode.
It doesn't matter whether it's valid or not, and we've no way of guaranteeing that anyway. We just have to make sure we don't generate an infinitely long instruction. On a related note, I notice that we don't enforce x86 instruction length limits. > Backtracking should not be hard if we register the last cc pointer each > time we finish translating an insn. I'll think about this solution, > which really seems feasible to me. Right. You only have to worry about backtracking the state that's lives across insns and is not constant within a TB. For x86 I think this is dc->pc, dc->cc_op, gen_opc_ptr and nb_gen_labels. Plus you need to reset dc->is_jmp to zero. gen_opparam_ptr is not used after disassembly, so can be ignored. Paul