Skip to contentSkip to conversation

Drivers: hv: Fix definition of hypercall input & output arg variables

PATCH In review Michael Kelley 2 participants 3 messages Dec 28, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Drivers: hv: Fix definition of hypercall input & output arg variables

The percpu variables hyperv_pcpu_input_arg and hyperv_pcpu_output_arg have been incorrectly defined since their inception. The __percpu qualifier should be associated with the void * (i.e., a pointer), not with the target of the pointer. This distinction makes no difference to gcc and the generated code, but sparse correctly complains. Fix the definitions in the interest of general correctness in addition to making sparse happy.

No functional change.

---
 drivers/hv/hv_common.c         | 4 ++--
 include/asm-generic/mshyperv.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/hv/hv_common.c +2 -2
index 7be173a..7477e5a 100644
@@ -44,10 +44,10 @@
 u32 hv_max_vp_index;
 EXPORT_SYMBOL_GPL(hv_max_vp_index);
 
-void  __percpu **hyperv_pcpu_input_arg;
+void * __percpu *hyperv_pcpu_input_arg;
 EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg);
 
-void  __percpu **hyperv_pcpu_output_arg;
+void * __percpu *hyperv_pcpu_output_arg;
 EXPORT_SYMBOL_GPL(hyperv_pcpu_output_arg);
 
 /*
include/asm-generic/mshyperv.h +2 -2
index 3e2248ac..95b7888 100644
@@ -49,8 +49,8 @@ struct ms_hyperv_info {
 };
 extern struct ms_hyperv_info ms_hyperv;
 
-extern void  __percpu  **hyperv_pcpu_input_arg;
-extern void  __percpu  **hyperv_pcpu_output_arg;
+extern void * __percpu *hyperv_pcpu_input_arg;
+extern void * __percpu *hyperv_pcpu_output_arg;
 
 extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
 extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/2 x86/hyperv: Fix definition of hv_ghcb_pg variable

The percpu variable hv_ghcb_pg is incorrectly defined. The __percpu qualifier should be associated with the union hv_ghcb * (i.e., a pointer), not with the target of the pointer. This distinction makes no difference to gcc and the generated code, but sparse correctly complains. Fix the definition in the interest of general correctness in addition to making sparse happy.

No functional change.

Fixes 0cc4f6d9f0b9 ("x86/hyperv: Initialize GHCB page in Isolation VM")
---
 arch/x86/hyperv/hv_init.c       | 2 +-
 arch/x86/include/asm/mshyperv.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/hyperv/hv_init.c +1 -1
index 96eb7db..99afe77 100644
@@ -36,7 +36,7 @@
 void *hv_hypercall_pg;
 EXPORT_SYMBOL_GPL(hv_hypercall_pg);
 
-union hv_ghcb __percpu **hv_ghcb_pg;
+union hv_ghcb * __percpu *hv_ghcb_pg;
 
 /* Storage to save the hypercall page temporarily for hibernation */
 static void *hv_hypercall_pg_saved;
arch/x86/include/asm/mshyperv.h +1 -1
index da3972f..498317d 100644
@@ -30,7 +30,7 @@ typedef int (*hyperv_fill_flush_list_func)(
 
 extern u64 hv_current_partition_id;
 
-extern union hv_ghcb  __percpu **hv_ghcb_pg;
+extern union hv_ghcb * __percpu *hv_ghcb_pg;
 
 int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages);
 int hv_call_add_logical_proc(int node, u32 lp_index, u32 acpi_id);
Signature · 1 line
1.8.3.1
maintainer
#2 lore raw
In reply to Michael Kelley
Quoted 8 lines · Michael Kelley

The percpu variables hyperv_pcpu_input_arg and hyperv_pcpu_output_arg have been incorrectly defined since their inception. The __percpu qualifier should be associated with the void * (i.e., a pointer), not with the target of the pointer. This distinction makes no difference to gcc and the generated code, but sparse correctly complains. Fix the definitions in the interest of general correctness in addition to making sparse happy.

Quoted 4 lines

No functional change.

Good catch. I failed to interpret sparse's complaints.

Both patches queued to hyperv-next. Thanks.

Quoted 40 lines
---
 drivers/hv/hv_common.c         | 4 ++--
 include/asm-generic/mshyperv.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/hv/hv_common.c +2 -2
index 7be173a..7477e5a 100644
@@ -44,10 +44,10 @@
 u32 hv_max_vp_index;
 EXPORT_SYMBOL_GPL(hv_max_vp_index);
 
-void  __percpu **hyperv_pcpu_input_arg;
+void * __percpu *hyperv_pcpu_input_arg;
 EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg);
 
-void  __percpu **hyperv_pcpu_output_arg;
+void * __percpu *hyperv_pcpu_output_arg;
 EXPORT_SYMBOL_GPL(hyperv_pcpu_output_arg);
 
 /*
include/asm-generic/mshyperv.h +2 -2
index 3e2248ac..95b7888 100644
@@ -49,8 +49,8 @@ struct ms_hyperv_info {
 };
 extern struct ms_hyperv_info ms_hyperv;
 
-extern void  __percpu  **hyperv_pcpu_input_arg;
-extern void  __percpu  **hyperv_pcpu_output_arg;
+extern void * __percpu *hyperv_pcpu_input_arg;
+extern void * __percpu *hyperv_pcpu_output_arg;
 
 extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
 extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);
Signature · 1 line
1.8.3.1