lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP045ApB3p+xNOhs6qUcOBTWMybQ81nq=47r4eEmjuNs0E_WYw@mail.gmail.com>
Date:   Mon, 28 Nov 2016 08:13:15 -0800
From:   Kyle Huey <me@...ehuey.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     Radim Krčmář <rkrcmar@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
        Joerg Roedel <joro@...tes.org>, kvm list <kvm@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction

On Mon, Nov 28, 2016 at 3:42 AM, Paolo Bonzini <pbonzini@...hat.com> wrote:
>
>
> 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

They're not exactly the same.  For some reason I don't understand
kvm_vcpu_check_singlestep clears the trap flag.  Perhaps that is also
a bug?

- Kyle

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ