Skip to content

Commit b694011

Browse files
committed
Merge tag 'hyperv-next-signed-20210629' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
Pull hyperv updates from Wei Liu: "Just a few minor enhancement patches and bug fixes" * tag 'hyperv-next-signed-20210629' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: PCI: hv: Add check for hyperv_initialized in init_hv_pci_drv() Drivers: hv: Move Hyper-V extended capability check to arch neutral code drivers: hv: Fix missing error code in vmbus_connect() x86/hyperv: fix logical processor creation hv_utils: Fix passing zero to 'PTR_ERR' warning scsi: storvsc: Use blk_mq_unique_tag() to generate requestIDs Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer hv_balloon: Remove redundant assignment to region_start
2 parents c54b245 + 7d815f4 commit b694011

File tree

20 files changed

+317
-127
lines changed

20 files changed

+317
-127
lines changed

arch/x86/hyperv/hv_init.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -614,50 +614,3 @@ bool hv_is_isolation_supported(void)
614614
return hv_get_isolation_type() != HV_ISOLATION_TYPE_NONE;
615615
}
616616
EXPORT_SYMBOL_GPL(hv_is_isolation_supported);
617-
618-
/* Bit mask of the extended capability to query: see HV_EXT_CAPABILITY_xxx */
619-
bool hv_query_ext_cap(u64 cap_query)
620-
{
621-
/*
622-
* The address of the 'hv_extended_cap' variable will be used as an
623-
* output parameter to the hypercall below and so it should be
624-
* compatible with 'virt_to_phys'. Which means, it's address should be
625-
* directly mapped. Use 'static' to keep it compatible; stack variables
626-
* can be virtually mapped, making them incompatible with
627-
* 'virt_to_phys'.
628-
* Hypercall input/output addresses should also be 8-byte aligned.
629-
*/
630-
static u64 hv_extended_cap __aligned(8);
631-
static bool hv_extended_cap_queried;
632-
u64 status;
633-
634-
/*
635-
* Querying extended capabilities is an extended hypercall. Check if the
636-
* partition supports extended hypercall, first.
637-
*/
638-
if (!(ms_hyperv.priv_high & HV_ENABLE_EXTENDED_HYPERCALLS))
639-
return false;
640-
641-
/* Extended capabilities do not change at runtime. */
642-
if (hv_extended_cap_queried)
643-
return hv_extended_cap & cap_query;
644-
645-
status = hv_do_hypercall(HV_EXT_CALL_QUERY_CAPABILITIES, NULL,
646-
&hv_extended_cap);
647-
648-
/*
649-
* The query extended capabilities hypercall should not fail under
650-
* any normal circumstances. Avoid repeatedly making the hypercall, on
651-
* error.
652-
*/
653-
hv_extended_cap_queried = true;
654-
status &= HV_HYPERCALL_RESULT_MASK;
655-
if (status != HV_STATUS_SUCCESS) {
656-
pr_err("Hyper-V: Extended query capabilities hypercall failed 0x%llx\n",
657-
status);
658-
return false;
659-
}
660-
661-
return hv_extended_cap & cap_query;
662-
}
663-
EXPORT_SYMBOL_GPL(hv_query_ext_cap);

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static void __init hv_smp_prepare_cpus(unsigned int max_cpus)
236236
for_each_present_cpu(i) {
237237
if (i == 0)
238238
continue;
239-
ret = hv_call_add_logical_proc(numa_cpu_node(i), i, cpu_physical_id(i));
239+
ret = hv_call_add_logical_proc(numa_cpu_node(i), i, i);
240240
BUG_ON(ret);
241241
}
242242

drivers/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ obj-$(CONFIG_SOUNDWIRE) += soundwire/
160160

161161
# Virtualization drivers
162162
obj-$(CONFIG_VIRT_DRIVERS) += virt/
163-
obj-$(CONFIG_HYPERV) += hv/
163+
obj-$(subst m,y,$(CONFIG_HYPERV)) += hv/
164164

165165
obj-$(CONFIG_PM_DEVFREQ) += devfreq/
166166
obj-$(CONFIG_EXTCON) += extcon/

drivers/hv/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ hv_vmbus-y := vmbus_drv.o \
1111
channel_mgmt.o ring_buffer.o hv_trace.o
1212
hv_vmbus-$(CONFIG_HYPERV_TESTING) += hv_debugfs.o
1313
hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o
14+
15+
# Code that must be built-in
16+
obj-$(subst m,y,$(CONFIG_HYPERV)) += hv_common.o

drivers/hv/channel.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,15 @@ static int __vmbus_open(struct vmbus_channel *newchannel,
662662
newchannel->onchannel_callback = onchannelcallback;
663663
newchannel->channel_callback_context = context;
664664

665-
err = hv_ringbuffer_init(&newchannel->outbound, page, send_pages);
665+
if (!newchannel->max_pkt_size)
666+
newchannel->max_pkt_size = VMBUS_DEFAULT_MAX_PKT_SIZE;
667+
668+
err = hv_ringbuffer_init(&newchannel->outbound, page, send_pages, 0);
666669
if (err)
667670
goto error_clean_ring;
668671

669-
err = hv_ringbuffer_init(&newchannel->inbound,
670-
&page[send_pages], recv_pages);
672+
err = hv_ringbuffer_init(&newchannel->inbound, &page[send_pages],
673+
recv_pages, newchannel->max_pkt_size);
671674
if (err)
672675
goto error_clean_ring;
673676

@@ -1186,15 +1189,14 @@ EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
11861189
* vmbus_next_request_id - Returns a new request id. It is also
11871190
* the index at which the guest memory address is stored.
11881191
* Uses a spin lock to avoid race conditions.
1189-
* @rqstor: Pointer to the requestor struct
1192+
* @channel: Pointer to the VMbus channel struct
11901193
* @rqst_add: Guest memory address to be stored in the array
11911194
*/
1192-
u64 vmbus_next_request_id(struct vmbus_requestor *rqstor, u64 rqst_addr)
1195+
u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr)
11931196
{
1197+
struct vmbus_requestor *rqstor = &channel->requestor;
11941198
unsigned long flags;
11951199
u64 current_id;
1196-
const struct vmbus_channel *channel =
1197-
container_of(rqstor, const struct vmbus_channel, requestor);
11981200

11991201
/* Check rqstor has been initialized */
12001202
if (!channel->rqstor_size)
@@ -1228,16 +1230,15 @@ EXPORT_SYMBOL_GPL(vmbus_next_request_id);
12281230
/*
12291231
* vmbus_request_addr - Returns the memory address stored at @trans_id
12301232
* in @rqstor. Uses a spin lock to avoid race conditions.
1231-
* @rqstor: Pointer to the requestor struct
1233+
* @channel: Pointer to the VMbus channel struct
12321234
* @trans_id: Request id sent back from Hyper-V. Becomes the requestor's
12331235
* next request id.
12341236
*/
1235-
u64 vmbus_request_addr(struct vmbus_requestor *rqstor, u64 trans_id)
1237+
u64 vmbus_request_addr(struct vmbus_channel *channel, u64 trans_id)
12361238
{
1239+
struct vmbus_requestor *rqstor = &channel->requestor;
12371240
unsigned long flags;
12381241
u64 req_addr;
1239-
const struct vmbus_channel *channel =
1240-
container_of(rqstor, const struct vmbus_channel, requestor);
12411242

12421243
/* Check rqstor has been initialized */
12431244
if (!channel->rqstor_size)

drivers/hv/connection.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ int vmbus_connect(void)
232232
*/
233233

234234
for (i = 0; ; i++) {
235-
if (i == ARRAY_SIZE(vmbus_versions))
235+
if (i == ARRAY_SIZE(vmbus_versions)) {
236+
ret = -EDOM;
236237
goto cleanup;
238+
}
237239

238240
version = vmbus_versions[i];
239241
if (version > max_version)

drivers/hv/hv_balloon.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,6 @@ static void hot_add_req(struct work_struct *dummy)
10101010
* that need to be hot-added while ensuring the alignment
10111011
* and size requirements of Linux as it relates to hot-add.
10121012
*/
1013-
region_start = pg_start;
10141013
region_size = (pfn_cnt / HA_CHUNK) * HA_CHUNK;
10151014
if (pfn_cnt % HA_CHUNK)
10161015
region_size += HA_CHUNK;

drivers/hv/hv_common.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
/*
4+
* Architecture neutral utility routines for interacting with
5+
* Hyper-V. This file is specifically for code that must be
6+
* built-in to the kernel image when CONFIG_HYPERV is set
7+
* (vs. being in a module) because it is called from architecture
8+
* specific code under arch/.
9+
*
10+
* Copyright (C) 2021, Microsoft, Inc.
11+
*
12+
* Author : Michael Kelley <[email protected]>
13+
*/
14+
15+
#include <linux/types.h>
16+
#include <linux/export.h>
17+
#include <linux/bitfield.h>
18+
#include <asm/hyperv-tlfs.h>
19+
#include <asm/mshyperv.h>
20+
21+
22+
/* Bit mask of the extended capability to query: see HV_EXT_CAPABILITY_xxx */
23+
bool hv_query_ext_cap(u64 cap_query)
24+
{
25+
/*
26+
* The address of the 'hv_extended_cap' variable will be used as an
27+
* output parameter to the hypercall below and so it should be
28+
* compatible with 'virt_to_phys'. Which means, it's address should be
29+
* directly mapped. Use 'static' to keep it compatible; stack variables
30+
* can be virtually mapped, making them incompatible with
31+
* 'virt_to_phys'.
32+
* Hypercall input/output addresses should also be 8-byte aligned.
33+
*/
34+
static u64 hv_extended_cap __aligned(8);
35+
static bool hv_extended_cap_queried;
36+
u64 status;
37+
38+
/*
39+
* Querying extended capabilities is an extended hypercall. Check if the
40+
* partition supports extended hypercall, first.
41+
*/
42+
if (!(ms_hyperv.priv_high & HV_ENABLE_EXTENDED_HYPERCALLS))
43+
return false;
44+
45+
/* Extended capabilities do not change at runtime. */
46+
if (hv_extended_cap_queried)
47+
return hv_extended_cap & cap_query;
48+
49+
status = hv_do_hypercall(HV_EXT_CALL_QUERY_CAPABILITIES, NULL,
50+
&hv_extended_cap);
51+
52+
/*
53+
* The query extended capabilities hypercall should not fail under
54+
* any normal circumstances. Avoid repeatedly making the hypercall, on
55+
* error.
56+
*/
57+
hv_extended_cap_queried = true;
58+
if (!hv_result_success(status)) {
59+
pr_err("Hyper-V: Extended query capabilities hypercall failed 0x%llx\n",
60+
status);
61+
return false;
62+
}
63+
64+
return hv_extended_cap & cap_query;
65+
}
66+
EXPORT_SYMBOL_GPL(hv_query_ext_cap);

drivers/hv/hv_fcopy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ int hv_fcopy_init(struct hv_util_service *srv)
349349
{
350350
recv_buffer = srv->recv_buffer;
351351
fcopy_transaction.recv_channel = srv->channel;
352+
fcopy_transaction.recv_channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2;
352353

353354
/*
354355
* When this driver loads, the user level daemon that

drivers/hv/hv_kvp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ hv_kvp_init(struct hv_util_service *srv)
757757
{
758758
recv_buffer = srv->recv_buffer;
759759
kvp_transaction.recv_channel = srv->channel;
760+
kvp_transaction.recv_channel->max_pkt_size = HV_HYP_PAGE_SIZE * 4;
760761

761762
/*
762763
* When this driver loads, the user level daemon that

0 commit comments

Comments
 (0)