From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: kernel test robot <lkp@intel.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: kbuild-all@lists.01.org, kvm@vger.kernel.org,
Robert Hu <robert.hu@intel.com>,
Farrah Chen <farrah.chen@intel.com>,
Danmei Wei <danmei.wei@intel.com>
Subject: Re: [kvm:kvm-async-pf-int-5.8 3/6] arch/x86/kernel/kvm.c:330:6: warning: Variable 'pa' is reassigned a value before the old one has been used.
Date: Tue, 16 Jun 2020 09:00:09 +0200 [thread overview]
Message-ID: <87h7vbijgm.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <202006161327.d4RqWvaG%lkp@intel.com>
kernel test robot <lkp@intel.com> writes:
> tree: https://git.kernel.org/pub/scm/virt/kvm/kvm.git kvm-async-pf-int-5.8
> head: 62a9576cc07b7dcba951aaa00d6a55933c49367e
> commit: b1d405751cd5792856b1b8333aafaca6bf09ccbb [3/6] KVM: x86: Switch KVM guest to using interrupts for page ready APF delivery
> compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> cppcheck warnings: (new ones prefixed by >>)
>
>>> arch/x86/kernel/kvm.c:330:6: warning: Variable 'pa' is reassigned a value before the old one has been used. [redundantAssignment]
> pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
> ^
> arch/x86/kernel/kvm.c:326:0: note: Variable 'pa' is reassigned a value before the old one has been used.
> u64 pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
> ^
> arch/x86/kernel/kvm.c:330:6: note: Variable 'pa' is reassigned a value before the old one has been used.
> pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
> ^
>
> vim +/pa +330 arch/x86/kernel/kvm.c
>
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 322
> ed3cf15271fa15 Nicholas Krause 2015-05-20 323 static void kvm_guest_cpu_init(void)
> fd10cde9294f73 Gleb Natapov 2010-10-14 324 {
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 325 if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF_INT) && kvmapf) {
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 326 u64 pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
Leftover from previous version, this should just be 'u64 pa;'
> ef68017eb5704e Andy Lutomirski 2020-02-28 327
> ef68017eb5704e Andy Lutomirski 2020-02-28 328 WARN_ON_ONCE(!static_branch_likely(&kvm_async_pf_enabled));
> ef68017eb5704e Andy Lutomirski 2020-02-28 329
> ef68017eb5704e Andy Lutomirski 2020-02-28 @330 pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 331 pa |= KVM_ASYNC_PF_ENABLED | KVM_ASYNC_PF_DELIVERY_AS_INT;
> 52a5c155cf79f1 Wanpeng Li 2017-07-13 332
> fe2a3027e74e40 Radim Krčmář 2018-02-01 333 if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF_VMEXIT))
> fe2a3027e74e40 Radim Krčmář 2018-02-01 334 pa |= KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT;
> fe2a3027e74e40 Radim Krčmář 2018-02-01 335
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 336 wrmsrl(MSR_KVM_ASYNC_PF_INT, HYPERVISOR_CALLBACK_VECTOR);
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 337
> 52a5c155cf79f1 Wanpeng Li 2017-07-13 338 wrmsrl(MSR_KVM_ASYNC_PF_EN, pa);
> 89cbc76768c2fa Christoph Lameter 2014-08-17 339 __this_cpu_write(apf_reason.enabled, 1);
> 6bca69ada4bc20 Thomas Gleixner 2020-03-07 340 pr_info("KVM setup async PF for cpu %d\n", smp_processor_id());
> fd10cde9294f73 Gleb Natapov 2010-10-14 341 }
> d910f5c1064d7f Glauber Costa 2011-07-11 342
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 343 if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) {
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 344 unsigned long pa;
> 6bca69ada4bc20 Thomas Gleixner 2020-03-07 345
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 346 /* Size alignment is implied but just to make it explicit. */
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 347 BUILD_BUG_ON(__alignof__(kvm_apic_eoi) < 4);
> 89cbc76768c2fa Christoph Lameter 2014-08-17 348 __this_cpu_write(kvm_apic_eoi, 0);
> 89cbc76768c2fa Christoph Lameter 2014-08-17 349 pa = slow_virt_to_phys(this_cpu_ptr(&kvm_apic_eoi))
> 5dfd486c4750c9 Dave Hansen 2013-01-22 350 | KVM_MSR_ENABLED;
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 351 wrmsrl(MSR_KVM_PV_EOI_EN, pa);
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 352 }
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 353
> d910f5c1064d7f Glauber Costa 2011-07-11 354 if (has_steal_clock)
> d910f5c1064d7f Glauber Costa 2011-07-11 355 kvm_register_steal_time();
> fd10cde9294f73 Gleb Natapov 2010-10-14 356 }
> fd10cde9294f73 Gleb Natapov 2010-10-14 357
>
> :::::: The code at line 330 was first introduced by commit
> :::::: ef68017eb5704eb2b0577c3aa6619e13caf2b59f x86/kvm: Handle async page faults directly through do_page_fault()
>
> :::::: TO: Andy Lutomirski <luto@kernel.org>
> :::::: CC: Thomas Gleixner <tglx@linutronix.de>
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
--
Vitaly
WARNING: multiple messages have this Message-ID (diff)
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: kbuild-all@lists.01.org
Subject: Re: [kvm:kvm-async-pf-int-5.8 3/6] arch/x86/kernel/kvm.c:330:6: warning: Variable 'pa' is reassigned a value before the old one has been used.
Date: Tue, 16 Jun 2020 09:00:09 +0200 [thread overview]
Message-ID: <87h7vbijgm.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <202006161327.d4RqWvaG%lkp@intel.com>
[-- Attachment #1: Type: text/plain, Size: 4633 bytes --]
kernel test robot <lkp@intel.com> writes:
> tree: https://git.kernel.org/pub/scm/virt/kvm/kvm.git kvm-async-pf-int-5.8
> head: 62a9576cc07b7dcba951aaa00d6a55933c49367e
> commit: b1d405751cd5792856b1b8333aafaca6bf09ccbb [3/6] KVM: x86: Switch KVM guest to using interrupts for page ready APF delivery
> compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> cppcheck warnings: (new ones prefixed by >>)
>
>>> arch/x86/kernel/kvm.c:330:6: warning: Variable 'pa' is reassigned a value before the old one has been used. [redundantAssignment]
> pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
> ^
> arch/x86/kernel/kvm.c:326:0: note: Variable 'pa' is reassigned a value before the old one has been used.
> u64 pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
> ^
> arch/x86/kernel/kvm.c:330:6: note: Variable 'pa' is reassigned a value before the old one has been used.
> pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
> ^
>
> vim +/pa +330 arch/x86/kernel/kvm.c
>
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 322
> ed3cf15271fa15 Nicholas Krause 2015-05-20 323 static void kvm_guest_cpu_init(void)
> fd10cde9294f73 Gleb Natapov 2010-10-14 324 {
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 325 if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF_INT) && kvmapf) {
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 326 u64 pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
Leftover from previous version, this should just be 'u64 pa;'
> ef68017eb5704e Andy Lutomirski 2020-02-28 327
> ef68017eb5704e Andy Lutomirski 2020-02-28 328 WARN_ON_ONCE(!static_branch_likely(&kvm_async_pf_enabled));
> ef68017eb5704e Andy Lutomirski 2020-02-28 329
> ef68017eb5704e Andy Lutomirski 2020-02-28 @330 pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 331 pa |= KVM_ASYNC_PF_ENABLED | KVM_ASYNC_PF_DELIVERY_AS_INT;
> 52a5c155cf79f1 Wanpeng Li 2017-07-13 332
> fe2a3027e74e40 Radim Krčmář 2018-02-01 333 if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF_VMEXIT))
> fe2a3027e74e40 Radim Krčmář 2018-02-01 334 pa |= KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT;
> fe2a3027e74e40 Radim Krčmář 2018-02-01 335
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 336 wrmsrl(MSR_KVM_ASYNC_PF_INT, HYPERVISOR_CALLBACK_VECTOR);
> b1d405751cd579 Vitaly Kuznetsov 2020-05-25 337
> 52a5c155cf79f1 Wanpeng Li 2017-07-13 338 wrmsrl(MSR_KVM_ASYNC_PF_EN, pa);
> 89cbc76768c2fa Christoph Lameter 2014-08-17 339 __this_cpu_write(apf_reason.enabled, 1);
> 6bca69ada4bc20 Thomas Gleixner 2020-03-07 340 pr_info("KVM setup async PF for cpu %d\n", smp_processor_id());
> fd10cde9294f73 Gleb Natapov 2010-10-14 341 }
> d910f5c1064d7f Glauber Costa 2011-07-11 342
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 343 if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) {
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 344 unsigned long pa;
> 6bca69ada4bc20 Thomas Gleixner 2020-03-07 345
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 346 /* Size alignment is implied but just to make it explicit. */
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 347 BUILD_BUG_ON(__alignof__(kvm_apic_eoi) < 4);
> 89cbc76768c2fa Christoph Lameter 2014-08-17 348 __this_cpu_write(kvm_apic_eoi, 0);
> 89cbc76768c2fa Christoph Lameter 2014-08-17 349 pa = slow_virt_to_phys(this_cpu_ptr(&kvm_apic_eoi))
> 5dfd486c4750c9 Dave Hansen 2013-01-22 350 | KVM_MSR_ENABLED;
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 351 wrmsrl(MSR_KVM_PV_EOI_EN, pa);
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 352 }
> ab9cf4996bb989 Michael S. Tsirkin 2012-06-24 353
> d910f5c1064d7f Glauber Costa 2011-07-11 354 if (has_steal_clock)
> d910f5c1064d7f Glauber Costa 2011-07-11 355 kvm_register_steal_time();
> fd10cde9294f73 Gleb Natapov 2010-10-14 356 }
> fd10cde9294f73 Gleb Natapov 2010-10-14 357
>
> :::::: The code at line 330 was first introduced by commit
> :::::: ef68017eb5704eb2b0577c3aa6619e13caf2b59f x86/kvm: Handle async page faults directly through do_page_fault()
>
> :::::: TO: Andy Lutomirski <luto@kernel.org>
> :::::: CC: Thomas Gleixner <tglx@linutronix.de>
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
>
--
Vitaly
next prev parent reply other threads:[~2020-06-16 7:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 5:21 [kvm:kvm-async-pf-int-5.8 3/6] arch/x86/kernel/kvm.c:330:6: warning: Variable 'pa' is reassigned a value before the old one has been used kernel test robot
2020-06-16 5:21 ` kernel test robot
2020-06-16 7:00 ` Vitaly Kuznetsov [this message]
2020-06-16 7:00 ` Vitaly Kuznetsov
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=87h7vbijgm.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=danmei.wei@intel.com \
--cc=farrah.chen@intel.com \
--cc=kbuild-all@lists.01.org \
--cc=kvm@vger.kernel.org \
--cc=lkp@intel.com \
--cc=pbonzini@redhat.com \
--cc=robert.hu@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.