lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 19 Mar 2021 18:48:21 +0000
From:   Michael Kelley <mikelley@...rosoft.com>
To:     Xu Yihang <xuyihang@...wei.com>, KY Srinivasan <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "bp@...en8.de" <bp@...en8.de>, "x86@...nel.org" <x86@...nel.org>
CC:     "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH -next] x86: Fix unused variable 'msr_val' warning

From: Xu Yihang <xuyihang@...wei.com> Sent: Thursday, March 18, 2021 1:04 AM
> 
> Fixes the following W=1 kernel build warning(s):
> arch/x86/hyperv/hv_spinlock.c:28:16: warning: variable ‘msr_val’ set but not used [-
> Wunused-but-set-variable]
>   unsigned long msr_val;
> 
> Reported-by: Hulk Robot <hulkci@...wei.com>
> Signed-off-by: Xu Yihang <xuyihang@...wei.com>
> ---
>  arch/x86/hyperv/hv_spinlock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/hyperv/hv_spinlock.c b/arch/x86/hyperv/hv_spinlock.c
> index f3270c1fc48c..67bc15c7752a 100644
> --- a/arch/x86/hyperv/hv_spinlock.c
> +++ b/arch/x86/hyperv/hv_spinlock.c
> @@ -25,7 +25,7 @@ static void hv_qlock_kick(int cpu)
> 
>  static void hv_qlock_wait(u8 *byte, u8 val)
>  {
> -	unsigned long msr_val;
> +	unsigned long msr_val __maybe_unused;
>  	unsigned long flags;
> 
>  	if (in_nmi())
> --
> 2.17.1

This is one of those slightly weird cases where the side 
effect of reading the synthetic MSR provided by Hyper-V
is what we want.  The returned value is irrelevant and
never used, so the __maybe_unused annotation is correct.

Let me suggest updating the commit message, and adding
a brief comment to the code to explain this.  The side
effect behavior is described in the Hyper-V TLFS, though
perhaps not as clearly as it should be.

Michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ