Skip to content

Commit 66711cf

Browse files
committed
Merge tag 'hyperv-next-signed-20220322' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
Pull hyperv updates from Wei Liu: "Minor patches from various people" * tag 'hyperv-next-signed-20220322' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: x86/hyperv: Output host build info as normal Windows version number hv_balloon: rate-limit "Unhandled message" warning drivers: hv: log when enabling crash_kexec_post_notifiers hv_utils: Add comment about max VMbus packet size in VSS driver Drivers: hv: Compare cpumasks and not their weights in init_vp_index() Drivers: hv: Rename 'alloced' to 'allocated' Drivers: hv: vmbus: Use struct_size() helper in kmalloc()
2 parents 1ebdbeb + eeda29d commit 66711cf

File tree

8 files changed

+42
-27
lines changed

8 files changed

+42
-27
lines changed

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ static void __init ms_hyperv_init_platform(void)
310310
hv_host_info_ecx = cpuid_ecx(HYPERV_CPUID_VERSION);
311311
hv_host_info_edx = cpuid_edx(HYPERV_CPUID_VERSION);
312312

313-
pr_info("Hyper-V Host Build:%d-%d.%d-%d-%d.%d\n",
314-
hv_host_info_eax, hv_host_info_ebx >> 16,
315-
hv_host_info_ebx & 0xFFFF, hv_host_info_ecx,
316-
hv_host_info_edx >> 24, hv_host_info_edx & 0xFFFFFF);
313+
pr_info("Hyper-V: Host Build %d.%d.%d.%d-%d-%d\n",
314+
hv_host_info_ebx >> 16, hv_host_info_ebx & 0xFFFF,
315+
hv_host_info_eax, hv_host_info_edx & 0xFFFFFF,
316+
hv_host_info_ecx, hv_host_info_edx >> 24);
317317
}
318318

319319
if (ms_hyperv.features & HV_ACCESS_FREQUENCY_MSRS &&

drivers/hv/channel_mgmt.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
459459
* init_vp_index() can (re-)use the CPU.
460460
*/
461461
if (hv_is_perf_channel(channel))
462-
hv_clear_alloced_cpu(channel->target_cpu);
462+
hv_clear_allocated_cpu(channel->target_cpu);
463463

464464
/*
465465
* Upon suspend, an in-use hv_sock channel is marked as "rescinded" and
@@ -728,7 +728,7 @@ static void init_vp_index(struct vmbus_channel *channel)
728728
bool perf_chn = hv_is_perf_channel(channel);
729729
u32 i, ncpu = num_online_cpus();
730730
cpumask_var_t available_mask;
731-
struct cpumask *alloced_mask;
731+
struct cpumask *allocated_mask;
732732
u32 target_cpu;
733733
int numa_node;
734734

@@ -745,7 +745,7 @@ static void init_vp_index(struct vmbus_channel *channel)
745745
*/
746746
channel->target_cpu = VMBUS_CONNECT_CPU;
747747
if (perf_chn)
748-
hv_set_alloced_cpu(VMBUS_CONNECT_CPU);
748+
hv_set_allocated_cpu(VMBUS_CONNECT_CPU);
749749
return;
750750
}
751751

@@ -760,22 +760,21 @@ static void init_vp_index(struct vmbus_channel *channel)
760760
continue;
761761
break;
762762
}
763-
alloced_mask = &hv_context.hv_numa_map[numa_node];
763+
allocated_mask = &hv_context.hv_numa_map[numa_node];
764764

765-
if (cpumask_weight(alloced_mask) ==
766-
cpumask_weight(cpumask_of_node(numa_node))) {
765+
if (cpumask_equal(allocated_mask, cpumask_of_node(numa_node))) {
767766
/*
768767
* We have cycled through all the CPUs in the node;
769-
* reset the alloced map.
768+
* reset the allocated map.
770769
*/
771-
cpumask_clear(alloced_mask);
770+
cpumask_clear(allocated_mask);
772771
}
773772

774-
cpumask_xor(available_mask, alloced_mask,
773+
cpumask_xor(available_mask, allocated_mask,
775774
cpumask_of_node(numa_node));
776775

777776
target_cpu = cpumask_first(available_mask);
778-
cpumask_set_cpu(target_cpu, alloced_mask);
777+
cpumask_set_cpu(target_cpu, allocated_mask);
779778

780779
if (channel->offermsg.offer.sub_channel_index >= ncpu ||
781780
i > ncpu || !hv_cpuself_used(target_cpu, channel))

drivers/hv/hv_balloon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ static void balloon_onchannelcallback(void *context)
15631563
break;
15641564

15651565
default:
1566-
pr_warn("Unhandled message: type: %d\n", dm_hdr->type);
1566+
pr_warn_ratelimited("Unhandled message: type: %d\n", dm_hdr->type);
15671567

15681568
}
15691569
}

drivers/hv/hv_common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ int __init hv_common_init(void)
7979
* calling crash enlightment interface before running kdump
8080
* kernel.
8181
*/
82-
if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE)
82+
if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
8383
crash_kexec_post_notifiers = true;
84+
pr_info("Hyper-V: enabling crash_kexec_post_notifiers\n");
85+
}
8486

8587
/*
8688
* Allocate the per-CPU state for the hypercall input arg.

drivers/hv/hv_snapshot.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ static const int fw_versions[] = {
3131
UTIL_FW_VERSION
3232
};
3333

34+
/* See comment with struct hv_vss_msg regarding the max VMbus packet size */
35+
#define VSS_MAX_PKT_SIZE (HV_HYP_PAGE_SIZE * 2)
36+
3437
/*
3538
* Timeout values are based on expecations from host
3639
*/
@@ -298,7 +301,7 @@ void hv_vss_onchannelcallback(void *context)
298301
if (vss_transaction.state > HVUTIL_READY)
299302
return;
300303

301-
if (vmbus_recvpacket(channel, recv_buffer, HV_HYP_PAGE_SIZE * 2, &recvlen, &requestid)) {
304+
if (vmbus_recvpacket(channel, recv_buffer, VSS_MAX_PKT_SIZE, &recvlen, &requestid)) {
302305
pr_err_ratelimited("VSS request received. Could not read into recv buf\n");
303306
return;
304307
}
@@ -375,7 +378,7 @@ hv_vss_init(struct hv_util_service *srv)
375378
}
376379
recv_buffer = srv->recv_buffer;
377380
vss_transaction.recv_channel = srv->channel;
378-
vss_transaction.recv_channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2;
381+
vss_transaction.recv_channel->max_pkt_size = VSS_MAX_PKT_SIZE;
379382

380383
/*
381384
* When this driver loads, the user level daemon that

drivers/hv/hyperv_vmbus.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static inline bool hv_is_perf_channel(struct vmbus_channel *channel)
405405
return vmbus_devs[channel->device_id].perf_device;
406406
}
407407

408-
static inline bool hv_is_alloced_cpu(unsigned int cpu)
408+
static inline bool hv_is_allocated_cpu(unsigned int cpu)
409409
{
410410
struct vmbus_channel *channel, *sc;
411411

@@ -427,23 +427,23 @@ static inline bool hv_is_alloced_cpu(unsigned int cpu)
427427
return false;
428428
}
429429

430-
static inline void hv_set_alloced_cpu(unsigned int cpu)
430+
static inline void hv_set_allocated_cpu(unsigned int cpu)
431431
{
432432
cpumask_set_cpu(cpu, &hv_context.hv_numa_map[cpu_to_node(cpu)]);
433433
}
434434

435-
static inline void hv_clear_alloced_cpu(unsigned int cpu)
435+
static inline void hv_clear_allocated_cpu(unsigned int cpu)
436436
{
437-
if (hv_is_alloced_cpu(cpu))
437+
if (hv_is_allocated_cpu(cpu))
438438
return;
439439
cpumask_clear_cpu(cpu, &hv_context.hv_numa_map[cpu_to_node(cpu)]);
440440
}
441441

442-
static inline void hv_update_alloced_cpus(unsigned int old_cpu,
442+
static inline void hv_update_allocated_cpus(unsigned int old_cpu,
443443
unsigned int new_cpu)
444444
{
445-
hv_set_alloced_cpu(new_cpu);
446-
hv_clear_alloced_cpu(old_cpu);
445+
hv_set_allocated_cpu(new_cpu);
446+
hv_clear_allocated_cpu(old_cpu);
447447
}
448448

449449
#ifdef CONFIG_HYPERV_TESTING

drivers/hv/vmbus_drv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ void vmbus_on_msg_dpc(unsigned long data)
11291129
}
11301130

11311131
if (entry->handler_type == VMHT_BLOCKING) {
1132-
ctx = kmalloc(sizeof(*ctx) + payload_size, GFP_ATOMIC);
1132+
ctx = kmalloc(struct_size(ctx, msg.payload, payload_size), GFP_ATOMIC);
11331133
if (ctx == NULL)
11341134
return;
11351135

@@ -1874,7 +1874,7 @@ static ssize_t target_cpu_store(struct vmbus_channel *channel,
18741874

18751875
/* See init_vp_index(). */
18761876
if (hv_is_perf_channel(channel))
1877-
hv_update_alloced_cpus(origin_cpu, target_cpu);
1877+
hv_update_allocated_cpus(origin_cpu, target_cpu);
18781878

18791879
/* Currently set only for storvsc channels. */
18801880
if (channel->change_target_cpu_callback) {

include/uapi/linux/hyperv.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ struct hv_vss_check_dm_info {
9090
__u32 flags;
9191
} __attribute__((packed));
9292

93+
/*
94+
* struct hv_vss_msg encodes the fields that the Linux VSS
95+
* driver accesses. However, FREEZE messages from Hyper-V contain
96+
* additional LUN information that Linux doesn't use and are not
97+
* represented in struct hv_vss_msg. A received FREEZE message may
98+
* be as large as 6,260 bytes, so the driver must allocate at least
99+
* that much space, not sizeof(struct hv_vss_msg). Other messages
100+
* such as AUTO_RECOVER may be as large as 12,500 bytes. However,
101+
* because the Linux VSS driver responds that it doesn't support
102+
* auto-recovery, it should not receive such messages.
103+
*/
93104
struct hv_vss_msg {
94105
union {
95106
struct hv_vss_hdr vss_hdr;

0 commit comments

Comments
 (0)