Skip to contentSkip to conversation

KVM: apic: avoid calculating pending eoi from an uninitialized val

PATCH linmiaohe 1 participant 1 message Feb 21, 2020 KVM

lore
Share & tools
lore

linmiaohe

author
#0 lore raw
Quoted 6 lines · Sean Christopherson
Quoted 2 lines · Vitaly Kuznetsov

linmiaohe <[email protected]> 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.

Quoted 8 lines
	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.

Quoted 10 lines
Quoted 7 lines

Review

Quoted 3 lines
(quoted diff) +0 -0
 	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);

But why compilers don't complain?

Clang might?