Re: [PATCH v2 1/2] KVM: VMX: FIXED+PHYSICAL mode single target IPI fastpath

Vitaly Kuznetsov
2019-11-19T12:27:00Z

Wanpeng Li <kernellwp@gmail.com> writes:

> On Tue, 19 Nov 2019 at 19:54, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>>
>> Wanpeng Li <kernellwp@gmail.com> writes:
>>
>> > From: Wanpeng Li <wanpengli@tencent.com>
>> >
>> > + if (lapic_in_kernel(vcpu) && apic_x2apic_mode(vcpu->arch.apic)) {
>> > + /*
>> > + * fastpath to IPI target, FIXED+PHYSICAL which is popular
>> > + */
>> > + index = kvm_rcx_read(vcpu);
>> > + data = kvm_read_edx_eax(vcpu);
>> > +
>> > + if (((index - APIC_BASE_MSR) << 4 == APIC_ICR) &&
>>
>> What if index (RCX) is < APIC_BASE_MSR?
>
> How about if (index == (APIC_BASE_MSR + 0x300) &&
>

What about ' << 4', don't we still need it? :-) And better APIC_ICR
instead of 0x300...

Personally, I'd write something like

if (index > APIC_BASE_MSR && (index - APIC_BASE_MSR) == APIC_ICR >> 4)

and let compiler optimize this, I bet it's going to be equally good.

--
Vitaly