Re: [PATCH] svm/avic: Do not send AVIC doorbell to self

From: Suthikulpanit, Suravee
Date: Tue May 14 2019 - 11:53:52 EST


Alex,

On 5/7/2019 8:16 AM, Graf, Alexander wrote:
> [CAUTION:ÂExternalÂEmail]
>
> OnÂ03.05.19Â15:38,ÂSuthikulpanit,ÂSuraveeÂwrote:
>> AVICÂdoorbellÂisÂusedÂtoÂnotifyÂaÂrunningÂvCPUÂthatÂinterrupts
>> hasÂbeenÂinjectedÂintoÂtheÂvCPUÂAVICÂbackingÂpage.ÂCurrentÂlogic
>> checksÂonlyÂifÂaÂVCPUÂisÂrunningÂbeforeÂsendingÂaÂdoorbell.
>> However,ÂtheÂdoorbellÂisÂnotÂnecessaryÂifÂtheÂdestination
>> CPUÂisÂitself.
>>
>> AddÂlogicÂtoÂcheckÂcurrentlyÂrunningÂCPUÂbeforeÂsendingÂdoorbell.
>>
>> Signed-off-by:ÂSuraveeÂSuthikulpanit <suravee.suthikulpanit@xxxxxxx>
>
> Reviewed-by:ÂAlexanderÂGraf <graf@xxxxxxxxxx>

Thanks.

>> ---
>> ÂÂarch/x86/kvm/svm.cÂ|Â11Â+++++++----
>> ÂÂ1ÂfileÂchanged,Â7Âinsertions(+),Â4Âdeletions(-)
>>
>> diffÂ--gitÂa/arch/x86/kvm/svm.cÂb/arch/x86/kvm/svm.c
>> indexÂ122788f..4bbf6fcÂ100644
>> ---Âa/arch/x86/kvm/svm.c
>> +++Âb/arch/x86/kvm/svm.c
>> @@Â-5283,10Â+5283,13Â@@ÂstaticÂvoidÂsvm_deliver_avic_intr(structÂkvm_vcpuÂ*vcpu,ÂintÂvec)
>> ÂÂÂÂÂÂkvm_lapic_set_irr(vec,Âvcpu->arch.apic);
>> ÂÂÂÂÂÂsmp_mb__after_atomic();
>>
>> -ÂÂÂÂÂifÂ(avic_vcpu_is_running(vcpu))
>> -ÂÂÂÂÂÂÂÂÂÂÂÂÂwrmsrl(SVM_AVIC_DOORBELL,
>> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂkvm_cpu_get_apicid(vcpu->cpu));
>> -ÂÂÂÂÂelse
>> +ÂÂÂÂÂifÂ(avic_vcpu_is_running(vcpu))Â{Â>Â+ÂÂÂÂÂÂÂÂÂÂÂintÂcpuidÂ=Âvcpu->cpu;
>> +
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂifÂ(cpuidÂ!=Âget_cpu())
>
> TinyÂnitpick:ÂWhatÂwouldÂkeepÂyouÂfromÂcheckingÂvcpu->cpuÂdirectlyÂhere?

Nothing. Just coding style.

Thanks,
Suravee