Skip to contentSkip to conversation

x86/hyperv: conditionally build hv_get_nested_reg()

PATCH In review Tom Rix 3 participants 3 messages Jan 14, 2023 – Jan 17, 2023

Subsystems (3)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 x86/hyperv: conditionally build hv_get_nested_reg()

cppcheck reports
[arch/x86/kernel/cpu/mshyperv.c:44]: (style) The function 'hv_get_nested_reg' is never used.

hv_get_nested_reg() is built unconditially but is only used conditionally in hv_get_register() and hv_set_register() by CONFIG_HYPERV.

Move the conditional #if to also include hv_get_nested_reg()

Fixes 89acd9b2ff8e ("Drivers: hv: Setup synic registers in case of nested root partition")
---
 arch/x86/kernel/cpu/mshyperv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mshyperv.c +1 -1
index b8bb13daacf7..9ca202970569 100644
@@ -41,6 +41,7 @@ bool hv_root_partition;
 bool hv_nested;
 struct ms_hyperv_info ms_hyperv;
 
+#if IS_ENABLED(CONFIG_HYPERV)
 static inline unsigned int hv_get_nested_reg(unsigned int reg)
 {
 	switch (reg) {
@@ -61,7 +62,6 @@ static inline unsigned int hv_get_nested_reg(unsigned int reg)
 	}
 }
 
-#if IS_ENABLED(CONFIG_HYPERV)
 u64 hv_get_non_nested_register(unsigned int reg)
 {
 	u64 value;
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Tom Rix

cppcheck reports
[arch/x86/kernel/cpu/mshyperv.c:44]: (style) The function 'hv_get_nested_reg' is never used.

hv_get_nested_reg() is built unconditially but is only used conditionally in hv_get_register() and hv_set_register() by CONFIG_HYPERV.

Move the conditional #if to also include hv_get_nested_reg()

Fixes 89acd9b2ff8e ("Drivers: hv: Setup synic registers in case of nested root partition")
---
  arch/x86/kernel/cpu/mshyperv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mshyperv.c +1 -1
index b8bb13daacf7..9ca202970569 100644
@@ -41,6 +41,7 @@ bool hv_root_partition;
  bool hv_nested;
  struct ms_hyperv_info ms_hyperv;
 
+#if IS_ENABLED(CONFIG_HYPERV)
  static inline unsigned int hv_get_nested_reg(unsigned int reg)
  {
  	switch (reg) {
@@ -61,7 +62,6 @@ static inline unsigned int hv_get_nested_reg(unsigned int reg)
  	}
  }
 
-#if IS_ENABLED(CONFIG_HYPERV)
  u64 hv_get_non_nested_register(unsigned int reg)
  {
  	u64 value;
maintainer
#2 lore raw
Quoted 2 lines · Jinank Jain

I will just fold this into the buggy patch since that has not been sent to Linus.

Thanks Tom and Jinank.

Quoted 33 lines · Tom Rix
Quoted 32 lines

cppcheck reports
[arch/x86/kernel/cpu/mshyperv.c:44]: (style) The function 'hv_get_nested_reg' is never used.

hv_get_nested_reg() is built unconditially but is only used conditionally in hv_get_register() and hv_set_register() by CONFIG_HYPERV.

Move the conditional #if to also include hv_get_nested_reg()

Fixes 89acd9b2ff8e ("Drivers: hv: Setup synic registers in case of nested root partition")
---
  arch/x86/kernel/cpu/mshyperv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mshyperv.c +1 -1
index b8bb13daacf7..9ca202970569 100644
@@ -41,6 +41,7 @@ bool hv_root_partition;
  bool hv_nested;
  struct ms_hyperv_info ms_hyperv;
+#if IS_ENABLED(CONFIG_HYPERV)
  static inline unsigned int hv_get_nested_reg(unsigned int reg)
  {
  	switch (reg) {
@@ -61,7 +62,6 @@ static inline unsigned int hv_get_nested_reg(unsigned int reg)
  	}
  }
-#if IS_ENABLED(CONFIG_HYPERV)
  u64 hv_get_non_nested_register(unsigned int reg)
  {
  	u64 value;