From: Dan Carpenter <dan.carpenter@oracle.com>
To: suravee.suthikulpanit@amd.com
Cc: kvm@vger.kernel.org
Subject: [bug report] KVM: x86: Do not block APIC write for non ICR registers
Date: Thu, 4 Aug 2022 09:56:05 +0300 [thread overview]
Message-ID: <YutthQ3aWGGPk/sk@kili> (raw)
Hello Suravee Suthikulpanit,
The patch 1bd9dfec9fd4: "KVM: x86: Do not block APIC write for non
ICR registers" from Jul 25, 2022, leads to the following Smatch
static checker warning:
arch/x86/kvm/lapic.c:2302 kvm_apic_write_nodecode()
error: uninitialized symbol 'val'.
arch/x86/kvm/lapic.c
2282 void kvm_apic_write_nodecode(struct kvm_vcpu *vcpu, u32 offset)
2283 {
2284 struct kvm_lapic *apic = vcpu->arch.apic;
2285 u64 val;
2286
2287 if (apic_x2apic_mode(apic))
2288 kvm_lapic_msr_read(apic, offset, &val);
Originally, this was only called when "offset == APIC_ICR", but the
patch removed that condition. Now, if kvm_lapic_msr_read() returns 1
then "val" isn't initialized.
2289 else
2290 val = kvm_lapic_get_reg(apic, offset);
2291
2292 /*
2293 * ICR is a single 64-bit register when x2APIC is enabled. For legacy
2294 * xAPIC, ICR writes need to go down the common (slightly slower) path
2295 * to get the upper half from ICR2.
2296 */
2297 if (apic_x2apic_mode(apic) && offset == APIC_ICR) {
2298 kvm_apic_send_ipi(apic, (u32)val, (u32)(val >> 32));
2299 trace_kvm_apic_write(APIC_ICR, val);
2300 } else {
2301 /* TODO: optimize to just emulate side effect w/o one more write */
2302 kvm_lapic_reg_write(apic, offset, (u32)val);
The warning here is for when apic_x2apic_mode() is true but
"offset != APIC_ICR" and kvm_lapic_msr_read() returns 1.
2303 }
2304 }
regards,
dan carpenter
next reply other threads:[~2022-08-04 6:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-04 6:56 Dan Carpenter [this message]
2022-08-04 17:54 ` [bug report] KVM: x86: Do not block APIC write for non ICR registers Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YutthQ3aWGGPk/sk@kili \
--to=dan.carpenter@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=suravee.suthikulpanit@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox