Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1701673 > unrolled thread
| Started by | "Longpeng(Mike)" <longpeng2@huawei.com> |
|---|---|
| First post | 2017-08-02 05:30 +0200 |
| Last post | 2017-08-02 22:40 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] KVM: X86: init irq->level in kvm_pv_kick_cpu_op "Longpeng(Mike)" <longpeng2@huawei.com> - 2017-08-02 05:30 +0200
Re: [PATCH] KVM: X86: init irq->level in kvm_pv_kick_cpu_op Paolo Bonzini <pbonzini@redhat.com> - 2017-08-02 10:20 +0200
Re: [PATCH] KVM: X86: init irq->level in kvm_pv_kick_cpu_op Radim Krčmář <rkrcmar@redhat.com> - 2017-08-02 22:40 +0200
| From | "Longpeng(Mike)" <longpeng2@huawei.com> |
|---|---|
| Date | 2017-08-02 05:30 +0200 |
| Subject | [PATCH] KVM: X86: init irq->level in kvm_pv_kick_cpu_op |
| Message-ID | <u9Swa-4q3-13@gated-at.bofh.it> |
'lapic_irq' is a local variable and its 'level' field isn't initialized, so 'level' is random, it doesn't matter but makes UBSAN unhappy: UBSAN: Undefined behaviour in .../lapic.c:... load of value 10 is not a valid value for type '_Bool' ... Call Trace: [<ffffffff81f030b6>] dump_stack+0x1e/0x20 [<ffffffff81f03173>] ubsan_epilogue+0x12/0x55 [<ffffffff81f03b96>] __ubsan_handle_load_invalid_value+0x118/0x162 [<ffffffffa1575173>] kvm_apic_set_irq+0xc3/0xf0 [kvm] [<ffffffffa1575b20>] kvm_irq_delivery_to_apic_fast+0x450/0x910 [kvm] [<ffffffffa15858ea>] kvm_irq_delivery_to_apic+0xfa/0x7a0 [kvm] [<ffffffffa1517f4e>] kvm_emulate_hypercall+0x62e/0x760 [kvm] [<ffffffffa113141a>] handle_vmcall+0x1a/0x30 [kvm_intel] [<ffffffffa114e592>] vmx_handle_exit+0x7a2/0x1fa0 [kvm_intel] ... Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com> --- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6c97c82..b411f92 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6215,6 +6215,7 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid) lapic_irq.shorthand = 0; lapic_irq.dest_mode = 0; + lapic_irq.level = 0; lapic_irq.dest_id = apicid; lapic_irq.msi_redir_hint = false; -- 1.8.3.1
[toc] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2017-08-02 10:20 +0200 |
| Message-ID | <u9X2P-7mD-43@gated-at.bofh.it> |
| In reply to | #1701673 |
On 02/08/2017 05:20, Longpeng(Mike) wrote: > 'lapic_irq' is a local variable and its 'level' field isn't > initialized, so 'level' is random, it doesn't matter but > makes UBSAN unhappy: > > UBSAN: Undefined behaviour in .../lapic.c:... > load of value 10 is not a valid value for type '_Bool' > ... > Call Trace: > [<ffffffff81f030b6>] dump_stack+0x1e/0x20 > [<ffffffff81f03173>] ubsan_epilogue+0x12/0x55 > [<ffffffff81f03b96>] __ubsan_handle_load_invalid_value+0x118/0x162 > [<ffffffffa1575173>] kvm_apic_set_irq+0xc3/0xf0 [kvm] > [<ffffffffa1575b20>] kvm_irq_delivery_to_apic_fast+0x450/0x910 [kvm] > [<ffffffffa15858ea>] kvm_irq_delivery_to_apic+0xfa/0x7a0 [kvm] > [<ffffffffa1517f4e>] kvm_emulate_hypercall+0x62e/0x760 [kvm] > [<ffffffffa113141a>] handle_vmcall+0x1a/0x30 [kvm_intel] > [<ffffffffa114e592>] vmx_handle_exit+0x7a2/0x1fa0 [kvm_intel] > ... > > Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com> > --- > arch/x86/kvm/x86.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 6c97c82..b411f92 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6215,6 +6215,7 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid) > > lapic_irq.shorthand = 0; > lapic_irq.dest_mode = 0; > + lapic_irq.level = 0; > lapic_irq.dest_id = apicid; > lapic_irq.msi_redir_hint = false; Looks good. Thanks, Paolo
[toc] | [prev] | [next] | [standalone]
| From | Radim Krčmář <rkrcmar@redhat.com> |
|---|---|
| Date | 2017-08-02 22:40 +0200 |
| Message-ID | <ua8AW-6r3-27@gated-at.bofh.it> |
| In reply to | #1701673 |
2017-08-02 11:20+0800, Longpeng(Mike):
> 'lapic_irq' is a local variable and its 'level' field isn't
> initialized, so 'level' is random, it doesn't matter but
> makes UBSAN unhappy:
>
> UBSAN: Undefined behaviour in .../lapic.c:...
> load of value 10 is not a valid value for type '_Bool'
> ...
> Call Trace:
> [<ffffffff81f030b6>] dump_stack+0x1e/0x20
> [<ffffffff81f03173>] ubsan_epilogue+0x12/0x55
> [<ffffffff81f03b96>] __ubsan_handle_load_invalid_value+0x118/0x162
> [<ffffffffa1575173>] kvm_apic_set_irq+0xc3/0xf0 [kvm]
> [<ffffffffa1575b20>] kvm_irq_delivery_to_apic_fast+0x450/0x910 [kvm]
> [<ffffffffa15858ea>] kvm_irq_delivery_to_apic+0xfa/0x7a0 [kvm]
> [<ffffffffa1517f4e>] kvm_emulate_hypercall+0x62e/0x760 [kvm]
> [<ffffffffa113141a>] handle_vmcall+0x1a/0x30 [kvm_intel]
> [<ffffffffa114e592>] vmx_handle_exit+0x7a2/0x1fa0 [kvm_intel]
> ...
>
> Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
> ---
Applied, thanks.
---
Thinking whether it's time to change it to:
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 72d82ab1ee22..0c33642a4ff7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6215,15 +6215,11 @@ static int kvm_pv_clock_pairing(struct kvm_vcpu *vcpu, gpa_t paddr,
*/
static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid)
{
- struct kvm_lapic_irq lapic_irq;
+ struct kvm_lapic_irq lapic_irq = {
+ .dest_id = apicid,
+ .delivery_mode = APIC_DM_REMRD,
+ };
- lapic_irq.shorthand = 0;
- lapic_irq.dest_mode = 0;
- lapic_irq.level = 0;
- lapic_irq.dest_id = apicid;
- lapic_irq.msi_redir_hint = false;
-
- lapic_irq.delivery_mode = APIC_DM_REMRD;
kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL);
}
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web