All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Kyle Huey <me@kylehuey.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<x86@kernel.org>, "Joerg Roedel" <joro@8bytes.org>,
	"kvm list" <kvm@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction
Date: Mon, 28 Nov 2016 23:43:02 +0100	[thread overview]
Message-ID: <e9b65e89-ad5e-9e7e-4721-4e24c6681891@redhat.com> (raw)
In-Reply-To: <CAP045ArknpKMBts1m0geo7iMsxib-7kCp-8=JvR93g6WvXJz7w@mail.gmail.com>



On 28/11/2016 19:34, Kyle Huey wrote:
>> > The Intel manual says "The processor clears the TF flag before calling
>> > the exception handler" (17.3.1.4), so I think you should do it too.
> The processor does this automatically. "When accessing an exception or
> interrupt handler through either an interrupt gate or a trap gate, the
> processor clears the TF flag in the EFLAGS register after it saves the
> contents of the EFLAGS register on the stack." (Vol 3, 6.12.1.2)
> Empirically, this holds when injecting an exception on VM entry. If
> you take the x86/debug.c test from kvm-unit-tests and inspect RFLAGS
> in handle_db (not regs->rflags, but the actual RFLAGS register while
> running the exception handler) the TF is clear. And, if you modify my
> patch to clear TF before returning, the single stepping ceases after
> the CPUID instruction because the TF was in fact cleared for good.

Ok, then that would be a bug in kvm_vcpu_check_singlestep (because
kvm_vcpu_check_singlestep is mostly interesting for real mode emulation,
I checked kvm_inject_realmode_interrupt and it clears TF too, in
__emulate_int_real).

Paolo

      reply	other threads:[~2016-11-28 22:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28  4:18 [PATCH 0/5] KVM: VMX: Fix single stepping with emulated instructions Kyle Huey
2016-11-28  4:18 ` [PATCH 1/5] KVM: x86: Add a return value to kvm_emulate_cpuid Kyle Huey
2016-11-28  4:18 ` [PATCH 2/5] KVM: VMX: Reorder some skip_emulated_instruction calls Kyle Huey
2016-11-28  4:18 ` [PATCH 3/5] KVM: VMX: Move skip_emulated_instruction out of nested_vmx_check_vmcs12 Kyle Huey
2016-11-28  4:18 ` [PATCH 4/5] KVM: x86: Add a return value to skip_emulated_instruction and propagate it Kyle Huey
2016-11-28  4:18 ` [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction Kyle Huey
2016-11-28 11:42   ` Paolo Bonzini
2016-11-28 16:13     ` Kyle Huey
2016-11-28 17:19       ` Paolo Bonzini
2016-11-28 18:34         ` Kyle Huey
2016-11-28 22:43           ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e9b65e89-ad5e-9e7e-4721-4e24c6681891@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@kylehuey.com \
    --cc=mingo@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.