]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
x86/hyperv: stash and use the configured max VP index
authorWei Liu <liuwe@microsoft.com>
Wed, 29 Apr 2020 10:41:44 +0000 (11:41 +0100)
committerWei Liu <wl@xen.org>
Wed, 6 May 2020 09:40:42 +0000 (10:40 +0100)
The value returned from CPUID is the maximum number for virtual
processors supported by Hyper-V. It could be larger than the maximum
number of virtual processors configured.

Stash the configured number into a variable and use it in calculations.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/guest/hyperv/hyperv.c
xen/arch/x86/guest/hyperv/private.h
xen/arch/x86/guest/hyperv/tlb.c
xen/arch/x86/guest/hyperv/util.c

index 91a6782cd986a255b57e68771bec41cee555a7c4..84221b75145331fce48bd65a1896d76c188d46f2 100644 (file)
@@ -33,6 +33,7 @@ DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page);
 DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist);
 DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index);
 
+unsigned int __read_mostly hv_max_vp_index;
 static bool __read_mostly hcall_page_ready;
 
 static uint64_t generate_guest_id(void)
@@ -143,6 +144,9 @@ static int setup_hypercall_pcpu_arg(void)
     rdmsrl(HV_X64_MSR_VP_INDEX, vp_index_msr);
     this_cpu(hv_vp_index) = vp_index_msr;
 
+    if ( vp_index_msr > hv_max_vp_index )
+        hv_max_vp_index = vp_index_msr;
+
     return 0;
 }
 
index 354fc7f685a73e95137d5533bf76d670d67729ef..fea3e291e944ef8d22de7c8da7dd4f488167c428 100644 (file)
@@ -28,6 +28,7 @@
 DECLARE_PER_CPU(void *, hv_input_page);
 DECLARE_PER_CPU(void *, hv_vp_assist);
 DECLARE_PER_CPU(unsigned int, hv_vp_index);
+extern unsigned int hv_max_vp_index;
 
 static inline unsigned int hv_vp_index(unsigned int cpu)
 {
index 1d723d6ee67904b58afa2853360efb97630d3095..f249b259253daaa747dee5989d9f7d85a3be3846 100644 (file)
@@ -166,7 +166,7 @@ int hyperv_flush_tlb(const cpumask_t *mask, const void *va,
         {
             unsigned int vpid = hv_vp_index(cpu);
 
-            if ( vpid >= ms_hyperv.max_vp_index )
+            if ( vpid > hv_max_vp_index )
             {
                 local_irq_restore(irq_flags);
                 return -ENXIO;
index bec61c2afd87807f03ebf077fccf3ffae771a527..2c5f421b7bd9a5039ba59653a09b1e06700b2a3d 100644 (file)
@@ -33,7 +33,7 @@ int cpumask_to_vpset(struct hv_vpset *vpset,
 {
     int nr = 1;
     unsigned int cpu, vcpu_bank, vcpu_offset;
-    unsigned int max_banks = ms_hyperv.max_vp_index / 64;
+    unsigned int max_banks = hv_max_vp_index / 64;
 
     /* Up to 64 banks can be represented by valid_bank_mask */
     if ( max_banks > 64 )