Re: [PATCH 2/2] kvm: x86: Disallow invalid exceptions from userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 15, 2018 at 6:46 AM, Marc Orr <marcorr@xxxxxxxxxx> wrote:
> On Fri, Oct 12, 2018 at 11:05 AM Jim Mattson <jmattson@xxxxxxxxxx> wrote:

>> +       if (events->exception.injected) {
>> +               bool has_error_code = is_protmode(vcpu) &&
>> +                       x86_exception_has_error_code(events->exception.nr);
>> +
>> +               if (!!events->exception.has_error_code != has_error_code)
>
> Is !! necessary here? It's not used below, when extracting
> has_error_code from vcpu->arch.exception. Also, it would be nice to
> order these two if statements consistently (i.e., put the local
> variable, has_error_code, on the left side or right side of the != in
> both places).

The difference is that events->exception.has_error_code is of type
unsigned char, whereas vcpu->arch.exception.has_error_code is of type
bool. Alternatively, this could be written as:

                if ((bool)events->exception.has_error_code != has_error_code)

However, Linux convention appears to prefer !! over (bool).

I'll reorder the comparisons in v2.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux