Skip to contentSkip to conversation

hv_sock: fix ARM64 support

PATCH In review Hamza Mahfooz 5 participants 10 messages Apr 25 – Apr 28

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hv_sock: fix ARM64 support

VMBUS ring buffers must be page aligned. Therefore, the current value of 24K presents a challenge on ARM64 kernels (with 64K pages). So, use VMBUS_RING_SIZE() to ensure they are always aligned and large enough to hold all of the relevant data.

Fixes 77ffe33363c0 ("hv_sock: use HV_HYP_PAGE_SIZE for Hyper-V communication")
---
 net/vmw_vsock/hyperv_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/vmw_vsock/hyperv_transport.c +2 -2
index 069386a74557..40f09b23efa3 100644
@@ -375,10 +375,10 @@ static void hvs_open_connection(struct vmbus_channel *chan)
 	} else {
 		sndbuf = max_t(int, sk->sk_sndbuf, RINGBUFFER_HVS_SND_SIZE);
 		sndbuf = min_t(int, sndbuf, RINGBUFFER_HVS_MAX_SIZE);
-		sndbuf = ALIGN(sndbuf, HV_HYP_PAGE_SIZE);
+		sndbuf = VMBUS_RING_SIZE(sndbuf);
 		rcvbuf = max_t(int, sk->sk_rcvbuf, RINGBUFFER_HVS_RCV_SIZE);
 		rcvbuf = min_t(int, rcvbuf, RINGBUFFER_HVS_MAX_SIZE);
-		rcvbuf = ALIGN(rcvbuf, HV_HYP_PAGE_SIZE);
+		rcvbuf = VMBUS_RING_SIZE(rcvbuf);
 	}
 
 	chan->max_pkt_size = HVS_MAX_PKT_SIZE;
Signature · 1 line
2.54.0
#1 lore raw

PATCH 2/2 drm/hyperv: use VMBUS_RING_SIZE()

VMBUS ring buffers must be page aligned. So, use VMBUS_RING_SIZE() to ensure they are always aligned and large enough to hold all of the relevant data.

Fixes 76c56a5affeb ("drm/hyperv: Add DRM driver for hyperv synthetic video device")
---
 drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +1 -1
index 051ecc526832..753d97bff76f 100644
@@ -10,7 +10,7 @@
 
 #include "hyperv_drm.h"
 
-#define VMBUS_RING_BUFSIZE (256 * 1024)
+#define VMBUS_RING_BUFSIZE VMBUS_RING_SIZE(256 * 1024)
 #define VMBUS_VSP_TIMEOUT (10 * HZ)
 
 #define SYNTHVID_VERSION(major, minor) ((minor) << 16 | (major))
Signature · 1 line
2.54.0
Reviewed-by Saurabh Sengar on v1 2/2
#2 lore raw

RE: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

Quoted 29 lines

Subject: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

VMBUS ring buffers must be page aligned. So, use VMBUS_RING_SIZE() to ensure they are always aligned and large enough to hold all of the relevant data.

Fixes 76c56a5affeb ("drm/hyperv: Add DRM driver for hyperv synthetic video

device")

---
 drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +1 -2
index 051ecc526832..753d97bff76f 100644
@@ -10,7 +10,7 @@
 
 #include "hyperv_drm.h"
 
-#define VMBUS_RING_BUFSIZE (256 * 1024)
+#define VMBUS_RING_BUFSIZE VMBUS_RING_SIZE(256 * 1024)
 #define VMBUS_VSP_TIMEOUT (10 * HZ)
 
 #define SYNTHVID_VERSION(major, minor) ((minor) << 16 | (major))
--
Quoted 1 line

2.54.0

Although this lgtm, but this may change the behaviour on ARM64 systems with page size > 4K ? Have we tested it ?

author Applied
#3 lore raw

Re: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

Quoted 27 lines · Saurabh Singh Sengar
Quoted 27 lines

Subject: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

VMBUS ring buffers must be page aligned. So, use VMBUS_RING_SIZE() to ensure they are always aligned and large enough to hold all of the relevant data.

Fixes 76c56a5affeb ("drm/hyperv: Add DRM driver for hyperv synthetic video

device")

---
 drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +1 -1
index 051ecc526832..753d97bff76f 100644
@@ -10,7 +10,7 @@
 
 #include "hyperv_drm.h"
 
-#define VMBUS_RING_BUFSIZE (256 * 1024)
+#define VMBUS_RING_BUFSIZE VMBUS_RING_SIZE(256 * 1024)
 #define VMBUS_VSP_TIMEOUT (10 * HZ)
 
Quoted 6 lines
Quoted 3 lines
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +0 -1
 #define SYNTHVID_VERSION(major, minor) ((minor) << 16 | (major))
--

2.54.0

Although this lgtm, but this may change the behaviour on ARM64 systems with page size > 4K ? Have we tested it ?

Yup, I tested it on an ARM64 windows machine with a 64K page size guest kernel.

Quoted 2 lines

Pushed to drm-misc.

Quoted 1 line
maintainer
#4 lore raw

RE: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

Quoted 14 lines

From: Hamza Mahfooz <[email protected]>
Sent: Monday, April 27, 2026 4:52 AM
To: Saurabh Singh Sengar <[email protected]>
...

Quoted 9 lines · Saurabh Singh Sengar
Quoted 9 lines

Subject: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

VMBUS ring buffers must be page aligned. So, use VMBUS_RING_SIZE() to ensure they are always aligned and large enough to hold all of the relevant data.

Fixes 76c56a5affeb ("drm/hyperv: Add DRM driver for hyperv synthetic

video device")

IMO the Fixes tag is unnecessary because the existing VMBUS_RING_BUFSIZE is 256KB, which is already aligned to 4KB, 16KB and 64KB.

VMBUS_RING_SIZE(256 * 1024) is still 256KB.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
---
 drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +1 -1
index 051ecc526832..753d97bff76f 100644
@@ -10,7 +10,7 @@
 
 #include "hyperv_drm.h"
 
-#define VMBUS_RING_BUFSIZE (256 * 1024)
+#define VMBUS_RING_BUFSIZE VMBUS_RING_SIZE(256 * 1024)
 #define VMBUS_VSP_TIMEOUT (10 * HZ)
 
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +0 -1
 #define SYNTHVID_VERSION(major, minor) ((minor) << 16 | (major))
--

2.54.0

Although this lgtm, but this may change the behaviour on ARM64 systems

with page size > 4K ?

Actually the behavior won't change, because
VMBUS_RING_SIZE(256 * 1024) is still 256KB.

Quoted 9 lines
Quoted 1 line

Have we tested it ?

Yup, I tested it on an ARM64 windows machine with a 64K page size guest kernel.

Quoted 2 lines

Pushed to drm-misc.

#5 lore raw

RE: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

From: Dexuan Cui <[email protected]> Sent: Monday, April 27, 2026 11:42 AM

Quoted 12 lines
Quoted 12 lines

From: Hamza Mahfooz <[email protected]>
Sent: Monday, April 27, 2026 4:52 AM
To: Saurabh Singh Sengar <[email protected]>
...

Quoted 6 lines · Saurabh Singh Sengar
Quoted 6 lines

Subject: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

VMBUS ring buffers must be page aligned. So, use VMBUS_RING_SIZE() to ensure they are always aligned and large enough to hold all of the relevant data.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Fixes 76c56a5affeb ("drm/hyperv: Add DRM driver for hyperv synthetic

video device")

IMO the Fixes tag is unnecessary because the existing VMBUS_RING_BUFSIZE is 256KB, which is already aligned to 4KB, 16KB and 64KB.

VMBUS_RING_SIZE(256 * 1024) is still 256KB.

Not always. If PAGE_SIZE is 64KiB, VMBUS_RING_SIZE(256 * 1024) is 320KiB. If PAGE_SIZE is 16KiB or 4KiB, then VMBUS_RING_SIZE(256 * 1024) is indeed 256 KiB. See the explanation in the comment for VMBUS_RING_SIZE.

Michael

Quoted 38 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
 drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +1 -1
index 051ecc526832..753d97bff76f 100644
@@ -10,7 +10,7 @@
 
 #include "hyperv_drm.h"
 
-#define VMBUS_RING_BUFSIZE (256 * 1024)
+#define VMBUS_RING_BUFSIZE VMBUS_RING_SIZE(256 * 1024)
 #define VMBUS_VSP_TIMEOUT (10 * HZ)
 
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +0 -1
 #define SYNTHVID_VERSION(major, minor) ((minor) << 16 | (major))
--

2.54.0

Although this lgtm, but this may change the behaviour on ARM64 systems

with page size > 4K ?

Actually the behavior won't change, because
VMBUS_RING_SIZE(256 * 1024) is still 256KB.

Quoted 9 lines
Quoted 1 line

Have we tested it ?

Yup, I tested it on an ARM64 windows machine with a 64K page size guest kernel.

Quoted 2 lines

Pushed to drm-misc.

maintainer
#6 lore raw

RE: [PATCH 2/2] drm/hyperv: use VMBUS_RING_SIZE()

Quoted 6 lines

From: Michael Kelley <[email protected]>
Sent: Monday, April 27, 2026 12:06 PM

Quoted 4 lines

IMO the Fixes tag is unnecessary because the existing VMBUS_RING_BUFSIZE
is 256KB, which is already aligned to 4KB, 16KB and 64KB.

Quoted 8 lines
Quoted 1 line

VMBUS_RING_SIZE(256 * 1024) is still 256KB.

Not always. If PAGE_SIZE is 64KiB, VMBUS_RING_SIZE(256 * 1024) is 320KiB. If PAGE_SIZE is 16KiB or 4KiB, then VMBUS_RING_SIZE(256 * 1024) is indeed 256 KiB. See the explanation in the comment for VMBUS_RING_SIZE.

Michael

Thanks for correcting me!

I didn't realize that sizeof(struct hv_ring_buffer) is based on PAGE_SIZE, not on HV_HYP_PAGE_SIZE.

However, it looks like the Fixes tag is still not needed:

without the patch, we always pass two arguments of 256KB to vmbus_open().

with the patch, we still pass 256KB to vmbus_open() in the case of PAGE_SIZE=4KB or 16KB, and we pass 320KB in the case of PAGE_SIZE=64KB.

Both 320K and 256KB are multiples of PAGE_SIZE, so vmbus_open() -> vmbus_alloc_ring() doesn't return -EINVAL.

In the case of PAGE_SIZE=64KB, it's OK to pass 256KB to vmbus_open() here since the hyperv-drm driver doesn't really have to use a slightly bigger VMBus ringbuffer size.

Thanks,
Dexuan

maintainer Tested-by Reviewed-by on v1 1/2
#8 lore raw
In reply to Hamza Mahfooz
Quoted 6 lines

From: Hamza Mahfooz <[email protected]>
Sent: Saturday, April 25, 2026 11:17 AM
...

Fixes 77ffe33363c0 ("hv_sock: use HV_HYP_PAGE_SIZE for Hyper-V

communication")

It looks like 77ffe33363c0 was not tested with
CONFIG_ARM64_64K_PAGES=y...

Thanks for the fix!

Quoted 1 line
maintainer
#9 lore raw
In reply to Hamza Mahfooz
Quoted 4 lines · On Sat, 25 Apr 2026 11:17:18 -0700 Hamza Mahfooz wrote:

VMBUS ring buffers must be page aligned. Therefore, the current value of 24K presents a challenge on ARM64 kernels (with 64K pages). So, use VMBUS_RING_SIZE() to ensure they are always aligned and large enough to hold all of the relevant data.

Please split the fixes into two independent postings. They have to go via different trees AFAICT