[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] Possible problem emulating movntq, movss
>>> On 06.08.14 at 14:16, <JBeulich@xxxxxxxx> wrote: >>>> On 06.08.14 at 12:47, <vlutas@xxxxxxxxxxxxxxx> wrote: >> On 8/6/2014 12:54 PM, Jan Beulich wrote: >>>>>> On 06.08.14 at 10:57, <rcojocaru@xxxxxxxxxxxxxxx> wrote: >>>> We found that our HVM guests froze when trying to emulate movntq >>>> instructions. The solution seems to be to replace "goto done;" with >>>> "break;" at line 4191 (when handling "case 0x7f:") in >>>> xen/arch/x86/x86_emulate/x86_emulate.c. Otherwise the writeback part >>>> doesn't happen. >>>> >>>> If you're happy with the fix I can prepare a patch, otherwise please let >>>> me know if we're missing something. >>> No, that doesn't look right: There's nothing left to be written back at >>> that point (registers get updated with the instruction executed via the >>> on-stack stub, and memory gets written with immediately preceding >>> ops->write(). So without you being more specific about _what_ you >>> see going wrong I don't think I can give further advice. >> Except for maybe the instruction pointer? That doesn't seem to be updated >> anywhereexcept during the write-back phase (or maybe I'm missing the spot). >> The problem is that the guest gets stuck with the instruction pointer >> pointing to the sameinstruction (in our particular case it is >> "MOVDQU xmm0, xmmword ptr [rdx + rcx - 0x10]"),entering in an infinite >> loop (EPT violation - emulate), since the IP doesn't seem to be updated. > > Now that is indeed a problem, but not solved by simply replacing > the "goto done" with "break". I'll look into getting you a proper fix. Mind giving this one (lightly tested only) a try? Jan --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -720,29 +720,26 @@ do{ uint8_t stub[] = { _bytes, 0xc3 }; put_fpu(&fic); \ } while (0) -static unsigned long __get_rep_prefix( - struct cpu_user_regs *int_regs, - struct cpu_user_regs *ext_regs, +static unsigned long _get_rep_prefix( + const struct cpu_user_regs *int_regs, int ad_bytes) { - unsigned long ecx = ((ad_bytes == 2) ? (uint16_t)int_regs->ecx : - (ad_bytes == 4) ? (uint32_t)int_regs->ecx : - int_regs->ecx); - - /* Skip the instruction if no repetitions are required. */ - if ( ecx == 0 ) - ext_regs->eip = int_regs->eip; - - return ecx; + return (ad_bytes == 2) ? (uint16_t)int_regs->ecx : + (ad_bytes == 4) ? (uint32_t)int_regs->ecx : + int_regs->ecx; } #define get_rep_prefix() ({ \ unsigned long max_reps = 1; \ if ( rep_prefix() ) \ - max_reps = __get_rep_prefix(&_regs, ctxt->regs, ad_bytes); \ + max_reps = _get_rep_prefix(&_regs, ad_bytes); \ if ( max_reps == 0 ) \ - goto done; \ - max_reps; \ + { \ + /* Skip the instruction if no repetitions are required. */ \ + dst.type = OP_NONE; \ + goto writeback; \ + } \ + max_reps; \ }) static void __put_rep_prefix( @@ -3921,7 +3918,8 @@ x86_emulate( if ( !rc && (b & 1) && (ea.type == OP_MEM) ) rc = ops->write(ea.mem.seg, ea.mem.off, mmvalp, ea.bytes, ctxt); - goto done; + dst.type = OP_NONE; + break; } case 0x20: /* mov cr,reg */ @@ -4188,7 +4186,8 @@ x86_emulate( if ( !rc && (b != 0x6f) && (ea.type == OP_MEM) ) rc = ops->write(ea.mem.seg, ea.mem.off, mmvalp, ea.bytes, ctxt); - goto done; + dst.type = OP_NONE; + break; } case 0x80 ... 0x8f: /* jcc (near) */ { Attachment:
x86emul-IP-updates.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |