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


Groups > linux.kernel > #1531232

Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction

From Paolo Bonzini <pbonzini@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction
Date 2016-11-28 12:50 +0100
Message-ID <sIsBA-1xz-33@gated-at.bofh.it> (permalink)
References <sIlA6-5uV-3@gated-at.bofh.it> <sIlJM-5y0-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 28/11/2016 05:18, Kyle Huey wrote:
> +
> +	if (unlikely(vmx_get_rflags(vcpu) & X86_EFLAGS_TF)) {
> +		if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) {
> +			vcpu->run->debug.arch.dr6 = DR6_BS | DR6_FIXED_1 |
> +						    DR6_RTM;
> +			vcpu->run->debug.arch.pc = vcpu->arch.singlestep_rip;
> +			vcpu->run->debug.arch.exception = DB_VECTOR;
> +			vcpu->run->exit_reason = KVM_EXIT_DEBUG;
> +			return 0;
> +		}
> +
> +		/*
> +		 * "Certain debug exceptions may clear bit 0-3.  The
> +		 * remaining contents of the DR6 register are never
> +		 * cleared by the processor".
> +		 */
> +		vcpu->arch.dr6 &= ~15;
> +		vcpu->arch.dr6 |= DR6_BS | DR6_RTM;
> +		kvm_queue_exception(vcpu, DB_VECTOR);
> +	}

This code is pretty much the same as kvm_vcpu_check_singlestep.  Let's 
not duplicate the code and implement skip_emulated_instruction can be
implemented in x86.c, like

	unsigned long rflags = kvm_x86_ops->get_rflags(vcpu);
	int r = EMULATE_DONE;

	/* This would be the no_trap variant */
	kvm_x86_ops->skip_emulated_instruction(vcpu);
	kvm_vcpu_check_singlestep(vcpu, rflags, &r);
	return r == EMULATE_DONE;

(because x86.c/vmx.c/svm.c are separate modules, when moving the function
to x86.c you should rename it to kvm_skip_emulated_instruction).

Paolo

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


Thread

[PATCH 0/5] KVM: VMX: Fix single stepping with emulated instructions. Kyle Huey <me@kylehuey.com> - 2016-11-28 05:20 +0100
  [PATCH 4/5] KVM: x86: Add a return value to skip_emulated_instruction and propagate it. Kyle Huey <me@kylehuey.com> - 2016-11-28 05:20 +0100
  [PATCH 2/5] KVM: VMX: Reorder some skip_emulated_instruction calls Kyle Huey <me@kylehuey.com> - 2016-11-28 05:30 +0100
  [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction Kyle Huey <me@kylehuey.com> - 2016-11-28 05:30 +0100
    Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in  skip_emulated_instruction Paolo Bonzini <pbonzini@redhat.com> - 2016-11-28 12:50 +0100
      Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction Kyle Huey <me@kylehuey.com> - 2016-11-28 17:20 +0100
        Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in  skip_emulated_instruction Paolo Bonzini <pbonzini@redhat.com> - 2016-11-28 18:30 +0100
          Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction Kyle Huey <me@kylehuey.com> - 2016-11-28 19:40 +0100
            Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in  skip_emulated_instruction Paolo Bonzini <pbonzini@redhat.com> - 2016-11-28 23:50 +0100
  [PATCH 3/5] KVM: VMX: Move skip_emulated_instruction out of nested_vmx_check_vmcs12 Kyle Huey <me@kylehuey.com> - 2016-11-28 05:30 +0100
  [PATCH 1/5] KVM: x86: Add a return value to kvm_emulate_cpuid Kyle Huey <me@kylehuey.com> - 2016-11-28 05:30 +0100

csiph-web