lkml.org 
[lkml]   [2020]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] KVM: apic: avoid calculating pending eoi from an uninitialized val
Date
Sean Christopherson <sean.j.christopherson@intel.com> wrote:
>On Thu, Feb 20, 2020 at 05:33:17PM +0100, Vitaly Kuznetsov wrote:
>> linmiaohe <linmiaohe@huawei.com> writes:
>>
>
>Rather than initialize @val, I'd prefer to explicitly handle the error, similar to pv_eoi_clr_pending() and pv_eoi_set_pending(), e.g.
>
> u8 val;
>
> if (pv_eoi_get_user(vcpu, &val) < 0) {
> printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n",
> (unsigned long long)vcpu->arch.pv_eoi.msr_val);
> return false;
> }
> return val & 0x1;

Looks good. Handle the error explicitly can help remind us @val is unusable.
Will do. Thanks.

>> > if (pv_eoi_get_user(vcpu, &val) < 0)
>> > printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n",
>> > (unsigned long long)vcpu->arch.pv_eoi.msr_val);
>>
>> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>>
>> But why compilers don't complain?
>
>Clang might?
>

\
 
 \ /
  Last update: 2020-02-21 02:37    [W:0.031 / U:0.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site