KVM: x86: Initializing all kvm_lapic_irq fields in ioapic_write_indirect
PATCH v2 1/1 KVM: x86: Initializing all kvm_lapic_irq fields in ioapic_write_indirect
Previously all fields of structure kvm_lapic_irq were not initialized before it was passed to kvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing the msi_redir_hint field before passing to the kvm_bitmap_or_dest_vcpus(), may lead to a misbehavior of kvm_apic_map_get_dest_lapic(). This will specifically happen when the kvm_lowest_prio_delivery() returns TRUE due to a non-zero garbage value of msi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.
This patch initializes all the fields of kvm_lapic_irq based on the values of ioapic redirect_entry object before passing it on to kvm_bitmap_or_dest_vcpus().
--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kvm/ioapic.c +5 -2
@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq; - irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ; + irq.trig_mode = e->fields.trig_mode; + irq.shorthand =APIC_DEST_NOSHORT ; + irq.dest_id = e->fields.dest_id; + irq.msi_redir_hint = false;bitmap_zero (&vcpu_bitmap,16 );kvm_bitmap_or_dest_vcpus (ioapic->kvm, &irq, &vcpu_bitmap);
Signature · 1 line
1.8.3.1
Quoted 26 lines · Nitesh Narayan Lal
Previously all fields of structure
kvm_lapic_irqwere not initialized before it was passed tokvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing themsi_redir_hintfield before passing to thekvm_bitmap_or_dest_vcpus(), may lead to a misbehavior ofkvm_apic_map_get_dest_lapic(). This will specifically happen when thekvm_lowest_prio_delivery()returns TRUE due to a non-zero garbage value ofmsi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.This patch initializes all the fields of
kvm_lapic_irqbased on the values of ioapicredirect_entryobject before passing it on tokvm_bitmap_or_dest_vcpus().Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")Signed-off-by Nitesh Narayan Lal <[email protected]>--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kvm/ioapic.c +0
-0
arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 385
Quoted 10 lines
arch/x86/kvm/ioapic.c +1
-2@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq; - irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ;
'level' is bool in struct kvm_lapic_irq but other than that, is there a reason we set it to 'true' here? I understand that any particular setting is likely better than random and it should actually not be used without setting it first but still?
Quoted 7 lines
arch/x86/kvm/ioapic.c +4
-0+ irq.trig_mode = e->fields.trig_mode; + irq.shorthand =APIC_DEST_NOSHORT ; + irq.dest_id = e->fields.dest_id; + irq.msi_redir_hint = false;bitmap_zero (&vcpu_bitmap,16 );kvm_bitmap_or_dest_vcpus (ioapic->kvm, &irq, &vcpu_bitmap);
Signature · 1 line
Vitaly
Quoted 31 lines · Vitaly Kuznetsov
Quoted 29 lines · Nitesh Narayan Lal
Previously all fields of structure
kvm_lapic_irqwere not initialized before it was passed tokvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing themsi_redir_hintfield before passing to thekvm_bitmap_or_dest_vcpus(), may lead to a misbehavior ofkvm_apic_map_get_dest_lapic(). This will specifically happen when thekvm_lowest_prio_delivery()returns TRUE due to a non-zero garbage value ofmsi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.This patch initializes all the fields of
kvm_lapic_irqbased on the values of ioapicredirect_entryobject before passing it on tokvm_bitmap_or_dest_vcpus().Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")Signed-off-by Nitesh Narayan Lal <[email protected]>--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kvm/ioapic.c +0
-0@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq;
Quoted 10 lines
arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 385
Quoted 7 lines
arch/x86/kvm/ioapic.c +1
-2- irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ;'level' is bool in struct
kvm_lapic_irqbut other than that, is there a reason we set it to 'true' here? I understand that any particular setting is likely better than random
Yes, that is the only reason which I had in my mind while doing this change. I was not particularly sure about the value, so I copied what ioapic_serivce() is doing.
Quoted 10 lines
and it should actually not be used
without setting it first but still?Quoted 7 lines
arch/x86/kvm/ioapic.c +4
-0+ irq.trig_mode = e->fields.trig_mode; + irq.shorthand =APIC_DEST_NOSHORT ; + irq.dest_id = e->fields.dest_id; + irq.msi_redir_hint = false;bitmap_zero (&vcpu_bitmap,16 );kvm_bitmap_or_dest_vcpus (ioapic->kvm, &irq, &vcpu_bitmap);
Signature · 2 lines
Thanks Nitesh
Quoted 42 lines · Nitesh Narayan Lal
Quoted 31 lines · Vitaly Kuznetsov
Quoted 29 lines · Nitesh Narayan Lal
Previously all fields of structure
kvm_lapic_irqwere not initialized before it was passed tokvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing themsi_redir_hintfield before passing to thekvm_bitmap_or_dest_vcpus(), may lead to a misbehavior ofkvm_apic_map_get_dest_lapic(). This will specifically happen when thekvm_lowest_prio_delivery()returns TRUE due to a non-zero garbage value ofmsi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.This patch initializes all the fields of
kvm_lapic_irqbased on the values of ioapicredirect_entryobject before passing it on tokvm_bitmap_or_dest_vcpus().Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")Signed-off-by Nitesh Narayan Lal <[email protected]>--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kvm/ioapic.c +0
-0@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq;Quoted 10 lines
arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 385
Quoted 7 lines
arch/x86/kvm/ioapic.c +1
-2- irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ;'level' is bool in struct
kvm_lapic_irqbut other than that, is there a reason we set it to 'true' here? I understand that any particular setting is likely better than random
Quoted 3 lines
Yes, that is the only reason which I had in my mind while doing this change. I was not particularly sure about the value, so I copied what
ioapic_serivce()is doing.
Do you think I should skip setting this here?
Quoted 10 lines
Quoted 10 lines
and it should actually not be used
without setting it first but still?Quoted 7 lines
arch/x86/kvm/ioapic.c +4
-0+ irq.trig_mode = e->fields.trig_mode; + irq.shorthand =APIC_DEST_NOSHORT ; + irq.dest_id = e->fields.dest_id; + irq.msi_redir_hint = false;bitmap_zero (&vcpu_bitmap,16 );kvm_bitmap_or_dest_vcpus (ioapic->kvm, &irq, &vcpu_bitmap);
Signature · 1 line
Nitesh
Quoted 43 lines · Nitesh Narayan Lal
Quoted 42 lines · Nitesh Narayan Lal
Quoted 41 lines · Vitaly Kuznetsov
Quoted 26 lines · Nitesh Narayan Lal
Previously all fields of structure
kvm_lapic_irqwere not initialized before it was passed tokvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing themsi_redir_hintfield before passing to thekvm_bitmap_or_dest_vcpus(), may lead to a misbehavior ofkvm_apic_map_get_dest_lapic(). This will specifically happen when thekvm_lowest_prio_delivery()returns TRUE due to a non-zero garbage value ofmsi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.This patch initializes all the fields of
kvm_lapic_irqbased on the values of ioapicredirect_entryobject before passing it on tokvm_bitmap_or_dest_vcpus().Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")Signed-off-by Nitesh Narayan Lal <[email protected]>--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kvm/ioapic.c +0
-0arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 385
Quoted 10 lines
arch/x86/kvm/ioapic.c +1
-2@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq; - irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ;'level' is bool in struct
kvm_lapic_irqbut other than that, is there a reason we set it to 'true' here? I understand that any particular setting is likely better than random
Quoted 6 lines
Quoted 3 lines
Yes, that is the only reason which I had in my mind while doing this change. I was not particularly sure about the value, so I copied what
ioapic_serivce()is doing.Do you think I should skip setting this here?
Personally, i'd initialize it to 'false': usualy, if something is not properly initialized it's either 0 or garbage)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
and it should actually not be used
without setting it first but still?Quoted 7 lines
arch/x86/kvm/ioapic.c +4
-0+ irq.trig_mode = e->fields.trig_mode; + irq.shorthand =APIC_DEST_NOSHORT ; + irq.dest_id = e->fields.dest_id; + irq.msi_redir_hint = false;bitmap_zero (&vcpu_bitmap,16 );kvm_bitmap_or_dest_vcpus (ioapic->kvm, &irq, &vcpu_bitmap);
Signature · 1 line
Vitaly
Quoted 45 lines · Vitaly Kuznetsov
Quoted 43 lines · Nitesh Narayan Lal
Quoted 42 lines · Nitesh Narayan Lal
Quoted 41 lines · Vitaly Kuznetsov
Quoted 26 lines · Nitesh Narayan Lal
Previously all fields of structure
kvm_lapic_irqwere not initialized before it was passed tokvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing themsi_redir_hintfield before passing to thekvm_bitmap_or_dest_vcpus(), may lead to a misbehavior ofkvm_apic_map_get_dest_lapic(). This will specifically happen when thekvm_lowest_prio_delivery()returns TRUE due to a non-zero garbage value ofmsi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.This patch initializes all the fields of
kvm_lapic_irqbased on the values of ioapicredirect_entryobject before passing it on tokvm_bitmap_or_dest_vcpus().Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")Signed-off-by Nitesh Narayan Lal <[email protected]>--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kvm/ioapic.c +0
-0arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 385
Quoted 10 lines
arch/x86/kvm/ioapic.c +1
-2@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq; - irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ;'level' is bool in struct
kvm_lapic_irqbut other than that, is there a reason we set it to 'true' here? I understand that any particular setting is likely better than random
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Yes, that is the only reason which I had in my mind while doing this change. I was not particularly sure about the value, so I copied what
ioapic_serivce()is doing.Do you think I should skip setting this here?
Personally, i'd initialize it to 'false': usualy, if something is not properly initialized it's either 0 or garbage)
I think that's true, initializing it to 'false' might make more sense. Any other concerns or comments that I can improve?
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
and it should actually not be used
without setting it first but still?Quoted 7 lines
arch/x86/kvm/ioapic.c +4
-0+ irq.trig_mode = e->fields.trig_mode; + irq.shorthand =APIC_DEST_NOSHORT ; + irq.dest_id = e->fields.dest_id; + irq.msi_redir_hint = false;bitmap_zero (&vcpu_bitmap,16 );kvm_bitmap_or_dest_vcpus (ioapic->kvm, &irq, &vcpu_bitmap);
Signature · 1 line
Nitesh
Vitaly Kuznetsov
Reviewed-byQuoted 49 lines · Nitesh Narayan Lal
Quoted 48 lines · Vitaly Kuznetsov
Quoted 46 lines · Nitesh Narayan Lal
Quoted 45 lines · Nitesh Narayan Lal
Quoted 31 lines · Vitaly Kuznetsov
Quoted 29 lines · Nitesh Narayan Lal
Previously all fields of structure
kvm_lapic_irqwere not initialized before it was passed tokvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing themsi_redir_hintfield before passing to thekvm_bitmap_or_dest_vcpus(), may lead to a misbehavior ofkvm_apic_map_get_dest_lapic(). This will specifically happen when thekvm_lowest_prio_delivery()returns TRUE due to a non-zero garbage value ofmsi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.This patch initializes all the fields of
kvm_lapic_irqbased on the values of ioapicredirect_entryobject before passing it on tokvm_bitmap_or_dest_vcpus().Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")Signed-off-by Nitesh Narayan Lal <[email protected]>--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kvm/ioapic.c +0
-0@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq;Quoted 10 lines
arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 385
Quoted 7 lines
arch/x86/kvm/ioapic.c +1
-2- irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ;'level' is bool in struct
kvm_lapic_irqbut other than that, is there a reason we set it to 'true' here? I understand that any particular setting is likely better than randomYes, that is the only reason which I had in my mind while doing this change. I was not particularly sure about the value, so I copied what
ioapic_serivce()is doing.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Do you think I should skip setting this here?
Personally, i'd initialize it to 'false': usualy, if something is not properly initialized it's either 0 or garbage)
I think that's true, initializing it to 'false' might make more sense. Any other concerns or comments that I can improve?
Please add the missing space to the 'Fixes' tag:
and with that and irq.level initialized to 'false' feel free to add
tag. Thanks!
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
and it should actually not be used
without setting it first but still?Quoted 7 lines
arch/x86/kvm/ioapic.c +4
-0+ irq.trig_mode = e->fields.trig_mode; + irq.shorthand =APIC_DEST_NOSHORT ; + irq.dest_id = e->fields.dest_id; + irq.msi_redir_hint = false;bitmap_zero (&vcpu_bitmap,16 );kvm_bitmap_or_dest_vcpus (ioapic->kvm, &irq, &vcpu_bitmap);
Signature · 1 line
Vitaly
Quoted 53 lines · Vitaly Kuznetsov
Quoted 51 lines · Nitesh Narayan Lal
Quoted 50 lines · Vitaly Kuznetsov
Quoted 48 lines · Nitesh Narayan Lal
Quoted 42 lines · Nitesh Narayan Lal
Quoted 31 lines · Vitaly Kuznetsov
Quoted 29 lines · Nitesh Narayan Lal
Previously all fields of structure
kvm_lapic_irqwere not initialized before it was passed tokvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing themsi_redir_hintfield before passing to thekvm_bitmap_or_dest_vcpus(), may lead to a misbehavior ofkvm_apic_map_get_dest_lapic(). This will specifically happen when thekvm_lowest_prio_delivery()returns TRUE due to a non-zero garbage value ofmsi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.This patch initializes all the fields of
kvm_lapic_irqbased on the values of ioapicredirect_entryobject before passing it on tokvm_bitmap_or_dest_vcpus().Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")Signed-off-by Nitesh Narayan Lal <[email protected]>--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kvm/ioapic.c +0
-0@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq;Quoted 10 lines
arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 385
Quoted 7 lines
arch/x86/kvm/ioapic.c +1
-2- irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ;'level' is bool in struct
kvm_lapic_irqbut other than that, is there a reason we set it to 'true' here? I understand that any particular setting is likely better than randomQuoted 3 lines
Yes, that is the only reason which I had in my mind while doing this change. I was not particularly sure about the value, so I copied what
ioapic_serivce()is doing.Do you think I should skip setting this here?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Personally, i'd initialize it to 'false': usualy, if something is not properly initialized it's either 0 or garbage)
I think that's true, initializing it to 'false' might make more sense. Any other concerns or comments that I can improve?
Please add the missing space to the 'Fixes' tag:
Fixes 7ee30bc132c6 ("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")
My bad.
Quoted 6 lines
and with that and irq.level initialized to 'false' feel free to add
Reviewed-by Vitaly Kuznetsov <[email protected]>tag. Thanks!
Sure, thank you.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
and it should actually not be used
without setting it first but still?Quoted 7 lines
arch/x86/kvm/ioapic.c +4
-0+ irq.trig_mode = e->fields.trig_mode; + irq.shorthand =APIC_DEST_NOSHORT ; + irq.dest_id = e->fields.dest_id; + irq.msi_redir_hint = false;bitmap_zero (&vcpu_bitmap,16 );kvm_bitmap_or_dest_vcpus (ioapic->kvm, &irq, &vcpu_bitmap);
Signature · 2 lines
Nitesh My
Paolo Bonzini
maintainerQuoted 67 lines · Nitesh Narayan Lal
Quoted 53 lines · Vitaly Kuznetsov
Quoted 51 lines · Nitesh Narayan Lal
Quoted 50 lines · Vitaly Kuznetsov
Quoted 48 lines · Nitesh Narayan Lal
Quoted 42 lines · Nitesh Narayan Lal
Quoted 31 lines · Vitaly Kuznetsov
Quoted 29 lines · Nitesh Narayan Lal
Previously all fields of structure
kvm_lapic_irqwere not initialized before it was passed tokvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing themsi_redir_hintfield before passing to thekvm_bitmap_or_dest_vcpus(), may lead to a misbehavior ofkvm_apic_map_get_dest_lapic(). This will specifically happen when thekvm_lowest_prio_delivery()returns TRUE due to a non-zero garbage value ofmsi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate.This patch initializes all the fields of
kvm_lapic_irqbased on the values of ioapicredirect_entryobject before passing it on tokvm_bitmap_or_dest_vcpus().Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")Signed-off-by Nitesh Narayan Lal <[email protected]>--- arch/x86/kvm/ioapic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kvm/ioapic.c +0
-0@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)if (e->fields.delivery_mode ==APIC_DM_FIXED ) {struct kvm_lapic_irq irq;Quoted 10 lines
arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 385
Quoted 7 lines
arch/x86/kvm/ioapic.c +1
-2- irq.shorthand =APIC_DEST_NOSHORT ; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode <<8 ; - irq.dest_id = e->fields.dest_id; irq.dest_mode =kvm_lapic_irq_dest_mode (!!e->fields.dest_mode); + irq.level =1 ;'level' is bool in struct
kvm_lapic_irqbut other than that, is there a reason we set it to 'true' here? I understand that any particular setting is likely better than randomQuoted 3 lines
Yes, that is the only reason which I had in my mind while doing this change. I was not particularly sure about the value, so I copied what
ioapic_serivce()is doing.Do you think I should skip setting this here?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Personally, i'd initialize it to 'false': usualy, if something is not properly initialized it's either 0 or garbage)
I think that's true, initializing it to 'false' might make more sense. Any other concerns or comments that I can improve?
Please add the missing space to the 'Fixes' tag:
Fixes 7ee30bc132c6 ("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")My bad.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
and with that and irq.level initialized to 'false' feel free to add
Reviewed-by Vitaly Kuznetsov <[email protected]>tag. Thanks!
Sure, thank you.
I did the changes and applied the patch, thanks.
Paolo