lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat,  5 Dec 2020 18:30:02 +0100
From:   Stefan Eschenbacher <stefan.eschenbacher@....de>
To:     "K. Y. Srinivasan" <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Wei Liu <wei.liu@...nel.org>
Cc:     Stefan Eschenbacher <stefan.eschenbacher@....de>,
        linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-kernel@...cs.fau.de, Max Stolze <max.stolze@....de>
Subject: [PATCH 1/3] drivers/hv: make max_num_channels_supported configurable

To make the number of supported channels configurable, this patch
introduces uint max_num_channels_supported as module parameter.
Also macro MAX_NUM_CHANNELS_SUPPORTED_DEFAULT is introduced with
value 256, which is the currently used macro value.
MAX_NUM_CHANNELS_SUPPORTED was found and replaced in two locations.

During module initialization sanity checks are applied which will result
in EINVAL or ERANGE if the given value is no multiple of 32 or larger than
MAX_NUM_CHANNELS.

Signed-off-by: Stefan Eschenbacher <stefan.eschenbacher@....de>
Co-developed-by: Max Stolze <max.stolze@....de>
Signed-off-by: Max Stolze <max.stolze@....de>
---
 drivers/hv/hyperv_vmbus.h |  6 +++---
 drivers/hv/vmbus_drv.c    | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 02f3e8988836..edeee1c0497d 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -194,11 +194,11 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
 #define MAX_NUM_CHANNELS	((HV_HYP_PAGE_SIZE >> 1) << 3)
 
 /* The value here must be in multiple of 32 */
-/* TODO: Need to make this configurable */
-#define MAX_NUM_CHANNELS_SUPPORTED	256
+#define MAX_NUM_CHANNELS_SUPPORTED_DEFAULT	256
+extern uint max_num_channels_supported;
 
 #define MAX_CHANNEL_RELIDS					\
-	max(MAX_NUM_CHANNELS_SUPPORTED, HV_EVENT_FLAGS_COUNT)
+	max((ulong) max_num_channels_supported, (ulong) HV_EVENT_FLAGS_COUNT)
 
 enum vmbus_connect_state {
 	DISCONNECTED,
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 502f8cd95f6d..8f1c8a606b4a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -48,6 +48,11 @@ static int hyperv_cpuhp_online;
 
 static void *hv_panic_page;
 
+uint max_num_channels_supported = MAX_NUM_CHANNELS_SUPPORTED_DEFAULT;
+module_param(max_num_channels_supported, uint, 0);
+MODULE_PARM_DESC(max_num_channels_supported,
+	"Number of supported vmbus channels. Must be a multiple of 32 and equal to or less than 16348");
+
 /* Values parsed from ACPI DSDT */
 static int vmbus_irq;
 int vmbus_interrupt;
@@ -1220,7 +1225,7 @@ static void vmbus_chan_sched(struct hv_per_cpu_context *hv_cpu)
 	u32 maxbits, relid;
 
 	if (vmbus_proto_version < VERSION_WIN8) {
-		maxbits = MAX_NUM_CHANNELS_SUPPORTED;
+		maxbits = max_num_channels_supported;
 		recv_int_page = vmbus_connection.recv_int_page;
 	} else {
 		/*
@@ -2620,6 +2625,17 @@ static int __init hv_acpi_init(void)
 	if (!hv_is_hyperv_initialized())
 		return -ENODEV;
 
+	// Check if max_num_channels_supported is a multiple of 32 and smaller MAX_NUM_CHANNELS
+	if (max_num_channels_supported % 32 != 0) {
+		pr_err("max_num_channels_supported is %u, but must be a multiple of 32\n",
+			max_num_channels_supported);
+		return -EINVAL;
+	} else if (max_num_channels_supported > MAX_NUM_CHANNELS) {
+		pr_err("max_num_channels_supported is %u which exceeds maximum of %lu\n",
+			max_num_channels_supported, MAX_NUM_CHANNELS);
+		return -ERANGE;
+	}
+
 	init_completion(&probe_event);
 
 	/*
@@ -2641,6 +2657,8 @@ static int __init hv_acpi_init(void)
 	if (ret)
 		goto cleanup;
 
+	pr_info("Supporting up to %u channels\n", max_num_channels_supported);
+
 	hv_setup_kexec_handler(hv_kexec_handler);
 	hv_setup_crash_handler(hv_crash_handler);
 
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ