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>] [day] [month] [year] [list]
Message-ID: <20240620175214.515211-1-rkir@google.com>
Date: Thu, 20 Jun 2024 10:52:14 -0700
From: Roman Kiryanov <rkir@...gle.com>
To: mst@...hat.com, linux-kernel@...r.kernel.org
Cc: jansene@...gle.com, mett@...gle.com, jpcottin@...gle.com, 
	Roman Kiryanov <rkir@...gle.com>
Subject: [PATCH] UAPI: Make virtio_ring.h C++ friendly

virtio_ring.h is an UAPI files which could
be used by code outside of the linux kernel
which could be written in C++.

Google-Bug-Id: 331190993
Change-Id: Ib27c1e57c273ec5613b4e745a3ab4d53bdde5aac
Signed-off-by: Roman Kiryanov <rkir@...gle.com>
---
 include/uapi/linux/virtio_ring.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h
index f8c20d3de8da..be88871d512b 100644
--- a/include/uapi/linux/virtio_ring.h
+++ b/include/uapi/linux/virtio_ring.h
@@ -199,11 +199,13 @@ struct vring {
 static inline void vring_init(struct vring *vr, unsigned int num, void *p,
 			      unsigned long align)
 {
+	struct vring_desc *desc = (struct vring_desc *)p;
+
 	vr->num = num;
-	vr->desc = p;
-	vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
-	vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
-		+ align-1) & ~(align - 1));
+	vr->desc = desc;
+	vr->avail = (struct vring_avail *)(desc + num);
+	vr->used = (struct vring_used *)(((uintptr_t)&vr->avail->ring[num]
+		+ sizeof(__virtio16) + align-1) & ~(align - 1));
 }
 
 static inline unsigned vring_size(unsigned int num, unsigned long align)
-- 
2.45.2.741.gdbec12cfda-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ