public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Kyle Huey <me@kylehuey.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/5] KVM: VMX: Fix single stepping with emulated instructions
Date: Wed, 30 Nov 2016 19:41:57 +0100	[thread overview]
Message-ID: <20161130184156.GF1682@potion> (raw)
In-Reply-To: <20161129204041.8839-1-khuey@kylehuey.com>

2016-11-29 12:40-0800, Kyle Huey:
> KVM does not currently honor the trap flag when emulating instructions that
> cause VM exits. This is observable from guest userspace, try stepping on a
> CPUID instruction in gdb in a KVM guest. The program will stop two
> instructions after CPUID.
> 
> To fix this, add kvm_skip_emulated_instruction that calls
> kvm_x86_ops->skip_emulated_instruction and then kvm_vcpu_check_singlestep to
> check for RFLAGS.TF. Patch 4 does this. To handle both the guest setting TF
> and the KVM_GUESTDBG_SINGLESTEP cases we need to be able to indicate to
> callees that an exit to userspace is required. Patches 1-3 are largely
> plumbing to make this possible.
> 
> Traps triggered by task switch instructions require some additional handling
> and are not implemented. KVM_GUESTDBG_SINGLESTEP traps can be squashed by
> certain instructions which also trigger userspace exits, such as HALT,
> MOV CR8, and IO instructions. I believe (although I have not tested) that
> KVM will simply generate another trap on the next instruction, so this is
> no worse than the current behavior.
> 
> Patch 5 fixes an existing bug where kvm_vcpu_check_singlestep clears
> RFLAGS.TF when generating a singlestep trap. Bare silicon does not do this.

Looks good, applied to kvm/queue.

> These patches only fix this issue for VMX, and the handful of SVM cases that
> call the shared kvm_complete_insn_gp. I don't have AMD silicon to test on.

Added to TODO,

Thanks.

  parent reply	other threads:[~2016-11-30 18:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29 20:40 [PATCH v2 0/5] KVM: VMX: Fix single stepping with emulated instructions Kyle Huey
2016-11-29 20:40 ` [PATCH v2 1/5] KVM: x86: Add a return value to kvm_emulate_cpuid Kyle Huey
2016-11-29 20:40 ` [PATCH v2 2/5] KVM: VMX: Reorder some skip_emulated_instruction calls Kyle Huey
2016-11-29 20:40 ` [PATCH v2 3/5] KVM: VMX: Move skip_emulated_instruction out of nested_vmx_check_vmcs12 Kyle Huey
2016-12-19 20:54   ` David Matlack
2016-11-29 20:40 ` [PATCH v2 4/5] KVM: x86: Add kvm_skip_emulated_instruction and use it Kyle Huey
2016-11-29 20:40 ` [PATCH v2 5/5] KVM: x86: Do not clear RFLAGS.TF when a singlestep trap occurs Kyle Huey
2016-11-30 18:41 ` Radim Krčmář [this message]
2016-11-30 18:52   ` [PATCH v2 0/5] KVM: VMX: Fix single stepping with emulated instructions Kyle Huey

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=20161130184156.GF1682@potion \
    --to=rkrcmar@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=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox