linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] KVM: VMX: Fix single stepping with emulated instructions.
@ 2016-11-28  4:18 Kyle Huey
  2016-11-28  4:18 ` [PATCH 1/5] KVM: x86: Add a return value to kvm_emulate_cpuid Kyle Huey
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Kyle Huey @ 2016-11-28  4:18 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Joerg Roedel
  Cc: kvm, linux-kernel

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, in skip_emulated_instruction we can check for RFLAGS.TF. Patch
5 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-4 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.

These patches only fix this issue for VMX. I don't have AMD silicon to test
on.

A small patch to kvm-unit-tests is coming in a separate email.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-11-28 22:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).