linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] x86: Fix unused variable 'msr_val' warning
@ 2021-03-18  8:03 Xu Yihang
  2021-03-19 18:48 ` Michael Kelley
  0 siblings, 1 reply; 10+ messages in thread
From: Xu Yihang @ 2021-03-18  8:03 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin, tglx, mingo, bp, x86
  Cc: linux-hyperv, linux-kernel, xuyihang

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@huawei.com>
Signed-off-by: Xu Yihang <xuyihang@huawei.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


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH -next] x86: Fix unused variable 'msr_val' warning
@ 2021-03-22  3:17 Xu Yihang
  2021-03-22 11:04 ` Wei Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Xu Yihang @ 2021-03-22  3:17 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin, tglx, mingo, bp, x86
  Cc: linux-hyperv, linux-kernel, xuyihang, johnny.chenyi, heying24

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;

As Hypervisor Top-Level Functional Specification states in chapter 7.5 Virtual Processor Idle Sleep State, "A partition which possesses the AccessGuestIdleMsr privilege (refer to section 4.2.2) may trigger entry into the virtual processor idle sleep state through a read to the hypervisor-defined MSR HV_X64_MSR_GUEST_IDLE". That means only a read is necessary, msr_val is not uesed, so __maybe_unused should be added.

Reference:
https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Xu Yihang <xuyihang@huawei.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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-03-24 11:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18  8:03 [PATCH -next] x86: Fix unused variable 'msr_val' warning Xu Yihang
2021-03-19 18:48 ` Michael Kelley
2021-03-22  3:17 Xu Yihang
2021-03-22 11:04 ` Wei Liu
2021-03-22 21:08 ` Ingo Molnar
2021-03-22 23:32   ` Michael Kelley
2021-03-23  0:13     ` Ingo Molnar
2021-03-23 11:34       ` Wei Liu
2021-03-23  2:43 ` Xu Yihang
2021-03-24 11:28   ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).