Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1533510

Re: [PATCH v2 0/5] KVM: VMX: Fix single stepping with emulated instructions

From Kyle Huey <me@kylehuey.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 0/5] KVM: VMX: Fix single stepping with emulated instructions
Date 2016-11-30 20:00 +0100
Message-ID <sJigO-1kn-21@gated-at.bofh.it> (permalink)
References <sIXvH-4Vd-3@gated-at.bofh.it> <sJi77-1gR-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Nov 30, 2016 at 10:41 AM, Radim Krčmář <rkrcmar@redhat.com> wrote:
> 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.

Great!  Thank you.

>> 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.

- Kyle

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/5] KVM: VMX: Fix single stepping with emulated instructions Kyle Huey <me@kylehuey.com> - 2016-11-29 21:50 +0100
  [PATCH v2 1/5] KVM: x86: Add a return value to kvm_emulate_cpuid Kyle Huey <me@kylehuey.com> - 2016-11-29 21:50 +0100
  [PATCH v2 3/5] KVM: VMX: Move skip_emulated_instruction out of nested_vmx_check_vmcs12 Kyle Huey <me@kylehuey.com> - 2016-11-29 21:50 +0100
  [PATCH v2 2/5] KVM: VMX: Reorder some skip_emulated_instruction calls Kyle Huey <me@kylehuey.com> - 2016-11-29 21:50 +0100
  [PATCH v2 4/5] KVM: x86: Add kvm_skip_emulated_instruction and use it. Kyle Huey <me@kylehuey.com> - 2016-11-29 21:50 +0100
  Re: [PATCH v2 0/5] KVM: VMX: Fix single stepping with emulated  instructions Radim Krčmář <rkrcmar@redhat.com> - 2016-11-30 19:50 +0100
    Re: [PATCH v2 0/5] KVM: VMX: Fix single stepping with emulated instructions Kyle Huey <me@kylehuey.com> - 2016-11-30 20:00 +0100

csiph-web