Re: [PATCH] KVM: apic: avoid calculating pending eoi from an uninitialized val
From: linmiaohe
Date: Thu Feb 20 2020 - 20:36:36 EST
Sean Christopherson <sean.j.christopherson@xxxxxxxxx> wrote:
>On Thu, Feb 20, 2020 at 05:33:17PM +0100, Vitaly Kuznetsov wrote:
>> linmiaohe <linmiaohe@xxxxxxxxxx> 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@xxxxxxxxxx>
>>
>> But why compilers don't complain?
>
>Clang might?
>