kvm:x86:Fix error handling in the function kvm_lapic_sync_to_vapic
Paolo Bonzini
maintainerQuoted 27 lines · Nicholas Krause
This fixes error handling in the function
kvm_lapic_sync_to_vapicto check the value of the call tokvm_write_guest_cachedto see if it failed by returning a error code and if so executeWARN_ONto allow the user to see in their logs the failure when executing the functionkvm_lapic_sync_to_vapic.Signed-off-by Nicholas Krause <[email protected]>--- arch/x86/kvm/lapic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)arch/x86/kvm/lapic.c +1
-1@@ -1935,7 +1935,7 @@ static void apic_sync_pv_eoi_to_guest(struct kvm_vcpu *vcpu,void kvm_lapic_sync_to_vapic (struct kvm_vcpu *vcpu) {u32 data, tpr; -int max_irr, max_isr; +int max_irr, max_isr, ret;struct kvm_lapic *apic = vcpu->arch.apic;apic_sync_pv_eoi_to_guest (vcpu, apic);@@ -1952,8 +1952,9 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu) max_isr =0 ;
arch/x86/kvm/lapic.c void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu) · line 1960
Quoted 10 lines
arch/x86/kvm/lapic.c +3
-2data = (tpr &0xff ) | ((max_isr &0xf0 ) <<8 ) | (max_irr <<24 ); -kvm_write_guest_cached (vcpu->kvm, &vcpu->arch.apic->vapic_cache, &data, -sizeof (u32)); + ret =kvm_write_guest_cached (vcpu->kvm, &vcpu->arch.apic->vapic_cache, &data, +sizeof (u32)); +WARN_ON (ret); }int kvm_lapic_set_vapic_addr (struct kvm_vcpu *vcpu,gpa_t vapic_addr)
Again... no. The error can be triggered by the guest. Incorrect behavior of the guest should *never* result in a WARN in the host.
Paolo