VMX does not automatically set rflags.rf during event injection. This patch does partial job, setting rflags.rf upon fault injection. It also marks that injection of trap/interrupt during rep-string instruction is not properly emulated. It is unclear how to do it efficiently without decoding the guest instruction before interrupt injection.
Signed-off-by: Nadav Amit <[email protected]> --- arch/x86/kvm/vmx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 0c9569b..8edb785 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2006,6 +2006,7 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr, bool reinject) { struct vcpu_vmx *vmx = to_vmx(vcpu); + unsigned long rflags; u32 intr_info = nr | INTR_INFO_VALID_MASK; if (!reinject && is_guest_mode(vcpu) && @@ -2017,6 +2018,12 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr, intr_info |= INTR_INFO_DELIVER_CODE_MASK; } + rflags = vmx_get_rflags(vcpu); + if (kvm_exception_type(nr) == EXCPT_FAULT) + vmx_set_rflags(vcpu, rflags | X86_EFLAGS_RF); + + /* TODO: Set rflags.rf on trap during rep-string */ + if (vmx->rmode.vm86_active) { int inc_eip = 0; if (kvm_exception_is_soft(nr)) @@ -4631,8 +4638,10 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu) intr |= INTR_TYPE_SOFT_INTR; vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, vmx->vcpu.arch.event_exit_inst_len); - } else + } else { + /* TODO: Set rflags.rf during rep-string */ intr |= INTR_TYPE_EXT_INTR; + } vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr); } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

