diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 8d415563e05b8be68a21e32d953c8ad7ae6adcc2..57743edfb4e2152676929111ac99b18d570ad65f 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -4683,7 +4683,10 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) goto done; } - ctxt->eflags &= ~EFLG_RF; + if (ctxt->rep_prefix && (ctxt->d & String)) + ctxt->eflags |= EFLG_RF; + else + ctxt->eflags &= ~EFLG_RF; if (ctxt->execute) { if (ctxt->d & Fastop) { @@ -4824,6 +4827,7 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) } goto done; /* skip rip writeback */ } + ctxt->eflags &= ~EFLG_RF; } ctxt->eip = ctxt->_eip;