Re: [PATCH v2 1/6] x86/hyper-v: move struct hv_flush_pcpu{,ex} definitions to common header

2018-04-12 Thread kbuild test robot
Hi Vitaly,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvm/linux-next]
[also build test WARNING on v4.16 next-20180412]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Vitaly-Kuznetsov/KVM-x86-hyperv-PV-TLB-flush-for-Windows-guests/20180413-025205
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> arch/x86/hyperv/mmu.c:107:22: sparse: incorrect type in initializer 
>> (different address spaces) @@expected void const [noderef] 
>> *__vpp_verify @@got struct hv_void const [noderef] 
>> *__vpp_verify @@
   arch/x86/hyperv/mmu.c:107:22:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/mmu.c:107:22:got struct hv_tlb_flush [noderef] 
**
>> arch/x86/hyperv/mmu.c:107:20: sparse: incorrect type in assignment 
>> (different address spaces) @@expected struct hv_tlb_flush **flush_pcpu 
>> @@got struct hv_tlb_flustruct hv_tlb_flush **flush_pcpu @@
   arch/x86/hyperv/mmu.c:107:20:expected struct hv_tlb_flush **flush_pcpu
   arch/x86/hyperv/mmu.c:107:20:got struct hv_tlb_flush [noderef] 
**
>> arch/x86/hyperv/mmu.c:194:22: sparse: incorrect type in initializer 
>> (different address spaces) @@expected void const [noderef] 
>> *__vpp_verify @@got struct hv_tlbvoid const [noderef] 
>> *__vpp_verify @@
   arch/x86/hyperv/mmu.c:194:22:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/mmu.c:194:22:got struct hv_tlb_flush_ex [noderef] 
**
>> arch/x86/hyperv/mmu.c:194:20: sparse: incorrect type in assignment 
>> (different address spaces) @@expected struct hv_tlb_flush_ex 
>> **flush_pcpu @@got struct hv_tlb_flustruct hv_tlb_flush_ex **flush_pcpu 
>> @@
   arch/x86/hyperv/mmu.c:194:20:expected struct hv_tlb_flush_ex **flush_pcpu
   arch/x86/hyperv/mmu.c:194:20:got struct hv_tlb_flush_ex [noderef] 
**
>> arch/x86/hyperv/mmu.c:286:28: sparse: incorrect type in assignment 
>> (different address spaces) @@expected struct hv_tlb_flush [noderef] 
>> **static [toplevel] pcpu_flush @@got h [noderef] **static 
>> [toplevel] pcpu_flush @@
   arch/x86/hyperv/mmu.c:286:28:expected struct hv_tlb_flush [noderef] 
**static [toplevel] pcpu_flush
   arch/x86/hyperv/mmu.c:286:28:got struct hv_tlb_flush *[noderef] 
*
>> arch/x86/hyperv/mmu.c:288:31: sparse: incorrect type in assignment 
>> (different address spaces) @@expected struct hv_tlb_flush_ex [noderef] 
>> **static [toplevel] pcpu_flush_ex @@got h_ex [noderef] 
>> **static [toplevel] pcpu_flush_ex @@
   arch/x86/hyperv/mmu.c:288:31:expected struct hv_tlb_flush_ex [noderef] 
**static [toplevel] pcpu_flush_ex
   arch/x86/hyperv/mmu.c:288:31:got struct hv_tlb_flush_ex *[noderef] 
*

vim +107 arch/x86/hyperv/mmu.c

628f54cc6 Vitaly Kuznetsov   2017-08-02   87  
2ffd9e33c Vitaly Kuznetsov   2017-08-02   88  static void 
hyperv_flush_tlb_others(const struct cpumask *cpus,
2ffd9e33c Vitaly Kuznetsov   2017-08-02   89
const struct flush_tlb_info *info)
2ffd9e33c Vitaly Kuznetsov   2017-08-02   90  {
2ffd9e33c Vitaly Kuznetsov   2017-08-02   91int cpu, vcpu, gva_n, 
max_gvas;
84d437db6 Vitaly Kuznetsov   2018-04-11   92struct hv_tlb_flush 
**flush_pcpu;
84d437db6 Vitaly Kuznetsov   2018-04-11   93struct hv_tlb_flush 
*flush;
2ffd9e33c Vitaly Kuznetsov   2017-08-02   94u64 status = U64_MAX;
2ffd9e33c Vitaly Kuznetsov   2017-08-02   95unsigned long flags;
2ffd9e33c Vitaly Kuznetsov   2017-08-02   96  
773b79f7a Vitaly Kuznetsov   2017-08-02   97
trace_hyperv_mmu_flush_tlb_others(cpus, info);
773b79f7a Vitaly Kuznetsov   2017-08-02   98  
2ffd9e33c Vitaly Kuznetsov   2017-08-02   99if (!pcpu_flush || 
!hv_hypercall_pg)
2ffd9e33c Vitaly Kuznetsov   2017-08-02  100goto do_native;
2ffd9e33c Vitaly Kuznetsov   2017-08-02  101  
2ffd9e33c Vitaly Kuznetsov   2017-08-02  102if (cpumask_empty(cpus))
2ffd9e33c Vitaly Kuznetsov   2017-08-02  103return;
2ffd9e33c Vitaly Kuznetsov   2017-08-02  104  
2ffd9e33c Vitaly Kuznetsov   2017-08-02  105local_irq_save(flags);
2ffd9e33c Vitaly Kuznetsov   2017-08-02  106  
60d73a7c9 Vitaly Kuznetsov   2017-10-05 @107flush_pcpu = 
this_cpu_ptr(pcpu_flush);
60d73a7c9 Vitaly Kuznetsov   2017-10-05  108  
60d73a7c9 Vitaly Kuznetsov   2017-10-05  109if 
(unlikely(!*flush_pcpu))
60d73a7c9 Vitaly Kuznetsov   2017-10-05  110*flush_pcpu = 
page_address(alloc_page(GFP_ATOMIC));
60d73a7c9 Vitaly Kuznetsov   2017-10-05  111  
60d73a7c9 Vitaly Kuznetsov   2017-10-05  

Re: [PATCH v2 1/6] x86/hyper-v: move struct hv_flush_pcpu{,ex} definitions to common header

2018-04-12 Thread kbuild test robot
Hi Vitaly,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvm/linux-next]
[also build test WARNING on v4.16 next-20180412]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Vitaly-Kuznetsov/KVM-x86-hyperv-PV-TLB-flush-for-Windows-guests/20180413-025205
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> arch/x86/hyperv/mmu.c:107:22: sparse: incorrect type in initializer 
>> (different address spaces) @@expected void const [noderef] 
>> *__vpp_verify @@got struct hv_void const [noderef] 
>> *__vpp_verify @@
   arch/x86/hyperv/mmu.c:107:22:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/mmu.c:107:22:got struct hv_tlb_flush [noderef] 
**
>> arch/x86/hyperv/mmu.c:107:20: sparse: incorrect type in assignment 
>> (different address spaces) @@expected struct hv_tlb_flush **flush_pcpu 
>> @@got struct hv_tlb_flustruct hv_tlb_flush **flush_pcpu @@
   arch/x86/hyperv/mmu.c:107:20:expected struct hv_tlb_flush **flush_pcpu
   arch/x86/hyperv/mmu.c:107:20:got struct hv_tlb_flush [noderef] 
**
>> arch/x86/hyperv/mmu.c:194:22: sparse: incorrect type in initializer 
>> (different address spaces) @@expected void const [noderef] 
>> *__vpp_verify @@got struct hv_tlbvoid const [noderef] 
>> *__vpp_verify @@
   arch/x86/hyperv/mmu.c:194:22:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/mmu.c:194:22:got struct hv_tlb_flush_ex [noderef] 
**
>> arch/x86/hyperv/mmu.c:194:20: sparse: incorrect type in assignment 
>> (different address spaces) @@expected struct hv_tlb_flush_ex 
>> **flush_pcpu @@got struct hv_tlb_flustruct hv_tlb_flush_ex **flush_pcpu 
>> @@
   arch/x86/hyperv/mmu.c:194:20:expected struct hv_tlb_flush_ex **flush_pcpu
   arch/x86/hyperv/mmu.c:194:20:got struct hv_tlb_flush_ex [noderef] 
**
>> arch/x86/hyperv/mmu.c:286:28: sparse: incorrect type in assignment 
>> (different address spaces) @@expected struct hv_tlb_flush [noderef] 
>> **static [toplevel] pcpu_flush @@got h [noderef] **static 
>> [toplevel] pcpu_flush @@
   arch/x86/hyperv/mmu.c:286:28:expected struct hv_tlb_flush [noderef] 
**static [toplevel] pcpu_flush
   arch/x86/hyperv/mmu.c:286:28:got struct hv_tlb_flush *[noderef] 
*
>> arch/x86/hyperv/mmu.c:288:31: sparse: incorrect type in assignment 
>> (different address spaces) @@expected struct hv_tlb_flush_ex [noderef] 
>> **static [toplevel] pcpu_flush_ex @@got h_ex [noderef] 
>> **static [toplevel] pcpu_flush_ex @@
   arch/x86/hyperv/mmu.c:288:31:expected struct hv_tlb_flush_ex [noderef] 
**static [toplevel] pcpu_flush_ex
   arch/x86/hyperv/mmu.c:288:31:got struct hv_tlb_flush_ex *[noderef] 
*

vim +107 arch/x86/hyperv/mmu.c

628f54cc6 Vitaly Kuznetsov   2017-08-02   87  
2ffd9e33c Vitaly Kuznetsov   2017-08-02   88  static void 
hyperv_flush_tlb_others(const struct cpumask *cpus,
2ffd9e33c Vitaly Kuznetsov   2017-08-02   89
const struct flush_tlb_info *info)
2ffd9e33c Vitaly Kuznetsov   2017-08-02   90  {
2ffd9e33c Vitaly Kuznetsov   2017-08-02   91int cpu, vcpu, gva_n, 
max_gvas;
84d437db6 Vitaly Kuznetsov   2018-04-11   92struct hv_tlb_flush 
**flush_pcpu;
84d437db6 Vitaly Kuznetsov   2018-04-11   93struct hv_tlb_flush 
*flush;
2ffd9e33c Vitaly Kuznetsov   2017-08-02   94u64 status = U64_MAX;
2ffd9e33c Vitaly Kuznetsov   2017-08-02   95unsigned long flags;
2ffd9e33c Vitaly Kuznetsov   2017-08-02   96  
773b79f7a Vitaly Kuznetsov   2017-08-02   97
trace_hyperv_mmu_flush_tlb_others(cpus, info);
773b79f7a Vitaly Kuznetsov   2017-08-02   98  
2ffd9e33c Vitaly Kuznetsov   2017-08-02   99if (!pcpu_flush || 
!hv_hypercall_pg)
2ffd9e33c Vitaly Kuznetsov   2017-08-02  100goto do_native;
2ffd9e33c Vitaly Kuznetsov   2017-08-02  101  
2ffd9e33c Vitaly Kuznetsov   2017-08-02  102if (cpumask_empty(cpus))
2ffd9e33c Vitaly Kuznetsov   2017-08-02  103return;
2ffd9e33c Vitaly Kuznetsov   2017-08-02  104  
2ffd9e33c Vitaly Kuznetsov   2017-08-02  105local_irq_save(flags);
2ffd9e33c Vitaly Kuznetsov   2017-08-02  106  
60d73a7c9 Vitaly Kuznetsov   2017-10-05 @107flush_pcpu = 
this_cpu_ptr(pcpu_flush);
60d73a7c9 Vitaly Kuznetsov   2017-10-05  108  
60d73a7c9 Vitaly Kuznetsov   2017-10-05  109if 
(unlikely(!*flush_pcpu))
60d73a7c9 Vitaly Kuznetsov   2017-10-05  110*flush_pcpu = 
page_address(alloc_page(GFP_ATOMIC));
60d73a7c9 Vitaly Kuznetsov   2017-10-05  111  
60d73a7c9 Vitaly Kuznetsov   2017-10-05  

[PATCH v2 1/6] x86/hyper-v: move struct hv_flush_pcpu{,ex} definitions to common header

2018-04-11 Thread Vitaly Kuznetsov
Hyper-V TLB flush hypercalls definitions will be required for KVM so move
them hyperv-tlfs.h. Structures also need to be renamed as '_pcpu' suffix is
invalid for a general-purpose definition.

Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/hyperv/mmu.c  | 40 ++
 arch/x86/include/asm/hyperv-tlfs.h | 20 +++
 2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index 56c9ebac946f..002fc565f8f2 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -13,32 +13,12 @@
 #define CREATE_TRACE_POINTS
 #include 
 
-/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
-struct hv_flush_pcpu {
-   u64 address_space;
-   u64 flags;
-   u64 processor_mask;
-   u64 gva_list[];
-};
-
-/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */
-struct hv_flush_pcpu_ex {
-   u64 address_space;
-   u64 flags;
-   struct {
-   u64 format;
-   u64 valid_bank_mask;
-   u64 bank_contents[];
-   } hv_vp_set;
-   u64 gva_list[];
-};
-
 /* Each gva in gva_list encodes up to 4096 pages to flush */
 #define HV_TLB_FLUSH_UNIT (4096 * PAGE_SIZE)
 
-static struct hv_flush_pcpu __percpu **pcpu_flush;
+static struct hv_tlb_flush __percpu **pcpu_flush;
 
-static struct hv_flush_pcpu_ex __percpu **pcpu_flush_ex;
+static struct hv_tlb_flush_ex __percpu **pcpu_flush_ex;
 
 /*
  * Fills in gva_list starting from offset. Returns the number of items added.
@@ -71,7 +51,7 @@ static inline int fill_gva_list(u64 gva_list[], int offset,
 }
 
 /* Return the number of banks in the resulting vp_set */
-static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex *flush,
+static inline int cpumask_to_vp_set(struct hv_tlb_flush_ex *flush,
const struct cpumask *cpus)
 {
int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
@@ -81,7 +61,7 @@ static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex 
*flush,
return 0;
 
/*
-* Clear all banks up to the maximum possible bank as hv_flush_pcpu_ex
+* Clear all banks up to the maximum possible bank as hv_tlb_flush_ex
 * structs are not cleared between calls, we risk flushing unneeded
 * vCPUs otherwise.
 */
@@ -109,8 +89,8 @@ static void hyperv_flush_tlb_others(const struct cpumask 
*cpus,
const struct flush_tlb_info *info)
 {
int cpu, vcpu, gva_n, max_gvas;
-   struct hv_flush_pcpu **flush_pcpu;
-   struct hv_flush_pcpu *flush;
+   struct hv_tlb_flush **flush_pcpu;
+   struct hv_tlb_flush *flush;
u64 status = U64_MAX;
unsigned long flags;
 
@@ -196,8 +176,8 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask 
*cpus,
   const struct flush_tlb_info *info)
 {
int nr_bank = 0, max_gvas, gva_n;
-   struct hv_flush_pcpu_ex **flush_pcpu;
-   struct hv_flush_pcpu_ex *flush;
+   struct hv_tlb_flush_ex **flush_pcpu;
+   struct hv_tlb_flush_ex *flush;
u64 status = U64_MAX;
unsigned long flags;
 
@@ -303,7 +283,7 @@ void hyper_alloc_mmu(void)
return;
 
if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED))
-   pcpu_flush = alloc_percpu(struct hv_flush_pcpu *);
+   pcpu_flush = alloc_percpu(struct hv_tlb_flush *);
else
-   pcpu_flush_ex = alloc_percpu(struct hv_flush_pcpu_ex *);
+   pcpu_flush_ex = alloc_percpu(struct hv_tlb_flush_ex *);
 }
diff --git a/arch/x86/include/asm/hyperv-tlfs.h 
b/arch/x86/include/asm/hyperv-tlfs.h
index 1c602ad4bda8..ccb1dffe0d84 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -703,4 +703,24 @@ struct hv_enlightened_vmcs {
 #define HV_STIMER_AUTOENABLE   (1ULL << 3)
 #define HV_STIMER_SINT(config) (__u8)(((config) >> 16) & 0x0F)
 
+/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
+struct hv_tlb_flush {
+   u64 address_space;
+   u64 flags;
+   u64 processor_mask;
+   u64 gva_list[];
+};
+
+/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */
+struct hv_tlb_flush_ex {
+   u64 address_space;
+   u64 flags;
+   struct {
+   u64 format;
+   u64 valid_bank_mask;
+   u64 bank_contents[];
+   } hv_vp_set;
+   u64 gva_list[];
+};
+
 #endif
-- 
2.14.3



[PATCH v2 1/6] x86/hyper-v: move struct hv_flush_pcpu{,ex} definitions to common header

2018-04-11 Thread Vitaly Kuznetsov
Hyper-V TLB flush hypercalls definitions will be required for KVM so move
them hyperv-tlfs.h. Structures also need to be renamed as '_pcpu' suffix is
invalid for a general-purpose definition.

Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/hyperv/mmu.c  | 40 ++
 arch/x86/include/asm/hyperv-tlfs.h | 20 +++
 2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index 56c9ebac946f..002fc565f8f2 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -13,32 +13,12 @@
 #define CREATE_TRACE_POINTS
 #include 
 
-/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
-struct hv_flush_pcpu {
-   u64 address_space;
-   u64 flags;
-   u64 processor_mask;
-   u64 gva_list[];
-};
-
-/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */
-struct hv_flush_pcpu_ex {
-   u64 address_space;
-   u64 flags;
-   struct {
-   u64 format;
-   u64 valid_bank_mask;
-   u64 bank_contents[];
-   } hv_vp_set;
-   u64 gva_list[];
-};
-
 /* Each gva in gva_list encodes up to 4096 pages to flush */
 #define HV_TLB_FLUSH_UNIT (4096 * PAGE_SIZE)
 
-static struct hv_flush_pcpu __percpu **pcpu_flush;
+static struct hv_tlb_flush __percpu **pcpu_flush;
 
-static struct hv_flush_pcpu_ex __percpu **pcpu_flush_ex;
+static struct hv_tlb_flush_ex __percpu **pcpu_flush_ex;
 
 /*
  * Fills in gva_list starting from offset. Returns the number of items added.
@@ -71,7 +51,7 @@ static inline int fill_gva_list(u64 gva_list[], int offset,
 }
 
 /* Return the number of banks in the resulting vp_set */
-static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex *flush,
+static inline int cpumask_to_vp_set(struct hv_tlb_flush_ex *flush,
const struct cpumask *cpus)
 {
int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
@@ -81,7 +61,7 @@ static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex 
*flush,
return 0;
 
/*
-* Clear all banks up to the maximum possible bank as hv_flush_pcpu_ex
+* Clear all banks up to the maximum possible bank as hv_tlb_flush_ex
 * structs are not cleared between calls, we risk flushing unneeded
 * vCPUs otherwise.
 */
@@ -109,8 +89,8 @@ static void hyperv_flush_tlb_others(const struct cpumask 
*cpus,
const struct flush_tlb_info *info)
 {
int cpu, vcpu, gva_n, max_gvas;
-   struct hv_flush_pcpu **flush_pcpu;
-   struct hv_flush_pcpu *flush;
+   struct hv_tlb_flush **flush_pcpu;
+   struct hv_tlb_flush *flush;
u64 status = U64_MAX;
unsigned long flags;
 
@@ -196,8 +176,8 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask 
*cpus,
   const struct flush_tlb_info *info)
 {
int nr_bank = 0, max_gvas, gva_n;
-   struct hv_flush_pcpu_ex **flush_pcpu;
-   struct hv_flush_pcpu_ex *flush;
+   struct hv_tlb_flush_ex **flush_pcpu;
+   struct hv_tlb_flush_ex *flush;
u64 status = U64_MAX;
unsigned long flags;
 
@@ -303,7 +283,7 @@ void hyper_alloc_mmu(void)
return;
 
if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED))
-   pcpu_flush = alloc_percpu(struct hv_flush_pcpu *);
+   pcpu_flush = alloc_percpu(struct hv_tlb_flush *);
else
-   pcpu_flush_ex = alloc_percpu(struct hv_flush_pcpu_ex *);
+   pcpu_flush_ex = alloc_percpu(struct hv_tlb_flush_ex *);
 }
diff --git a/arch/x86/include/asm/hyperv-tlfs.h 
b/arch/x86/include/asm/hyperv-tlfs.h
index 1c602ad4bda8..ccb1dffe0d84 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -703,4 +703,24 @@ struct hv_enlightened_vmcs {
 #define HV_STIMER_AUTOENABLE   (1ULL << 3)
 #define HV_STIMER_SINT(config) (__u8)(((config) >> 16) & 0x0F)
 
+/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
+struct hv_tlb_flush {
+   u64 address_space;
+   u64 flags;
+   u64 processor_mask;
+   u64 gva_list[];
+};
+
+/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */
+struct hv_tlb_flush_ex {
+   u64 address_space;
+   u64 flags;
+   struct {
+   u64 format;
+   u64 valid_bank_mask;
+   u64 bank_contents[];
+   } hv_vp_set;
+   u64 gva_list[];
+};
+
 #endif
-- 
2.14.3