Skip to contentSkip to conversation

vringh: fix copy direction of vringh_iov_push_kern()

PATCH In review Jason Wang 2 participants 5 messages Oct 24, 2019 – Oct 28, 2019

Subsystems (5)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 vringh: fix copy direction of vringh_iov_push_kern()

We want to copy from iov to buf, so the direction was wrong.

Note: no real user for the helper, but it will be used by future features.

---
 drivers/vhost/vringh.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/vhost/vringh.c +7 -1
index 08ad0d1f0476..a0a2d74967ef 100644
@@ -852,6 +852,12 @@ static inline int xfer_kern(void *src, void *dst, size_t len)
 	return 0;
 }
 
+static inline int kern_xfer(void *dst, void *src, size_t len)
+{
+	memcpy(dst, src, len);
+	return 0;
+}
+
 /**
  * vringh_init_kern - initialize a vringh for a kernelspace vring.
  * @vrh: the vringh to initialize.
@@ -958,7 +964,7 @@ EXPORT_SYMBOL(vringh_iov_pull_kern);
 ssize_t vringh_iov_push_kern(struct vringh_kiov *wiov,
 			     const void *src, size_t len)
 {
-	return vringh_iov_xfer(wiov, (void *)src, len, xfer_kern);
+	return vringh_iov_xfer(wiov, (void *)src, len, kern_xfer);
 }
 EXPORT_SYMBOL(vringh_iov_push_kern);
 
Signature · 1 line
2.19.1
#1 lore raw
Quoted 6 lines · Jason Wang

We want to copy from iov to buf, so the direction was wrong.

Note: no real user for the helper, but it will be used by future features.

I'm still inclined to merge it now, incorrect code tends to proliferate.

Quoted 32 lines
---
 drivers/vhost/vringh.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/vhost/vringh.c +7 -1
index 08ad0d1f0476..a0a2d74967ef 100644
@@ -852,6 +852,12 @@ static inline int xfer_kern(void *src, void *dst, size_t len)
 	return 0;
 }
 
+static inline int kern_xfer(void *dst, void *src, size_t len)
+{
+	memcpy(dst, src, len);
+	return 0;
+}
+
 /**
  * vringh_init_kern - initialize a vringh for a kernelspace vring.
  * @vrh: the vringh to initialize.
@@ -958,7 +964,7 @@ EXPORT_SYMBOL(vringh_iov_pull_kern);
 ssize_t vringh_iov_push_kern(struct vringh_kiov *wiov,
 			     const void *src, size_t len)
 {
-	return vringh_iov_xfer(wiov, (void *)src, len, xfer_kern);
+	return vringh_iov_xfer(wiov, (void *)src, len, kern_xfer);
 }
 EXPORT_SYMBOL(vringh_iov_push_kern);
 
Signature · 1 line
2.19.1
#2 lore raw
In reply to Jason Wang
Quoted 6 lines · Jason Wang

We want to copy from iov to buf, so the direction was wrong.

Note: no real user for the helper, but it will be used by future features.

I'm still inclined to merge it now, incorrect code tends to proliferate.

Quoted 32 lines
---
 drivers/vhost/vringh.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/vhost/vringh.c +7 -1
index 08ad0d1f0476..a0a2d74967ef 100644
@@ -852,6 +852,12 @@ static inline int xfer_kern(void *src, void *dst, size_t len)
 	return 0;
 }
 
+static inline int kern_xfer(void *dst, void *src, size_t len)
+{
+	memcpy(dst, src, len);
+	return 0;
+}
+
 /**
  * vringh_init_kern - initialize a vringh for a kernelspace vring.
  * @vrh: the vringh to initialize.
@@ -958,7 +964,7 @@ EXPORT_SYMBOL(vringh_iov_pull_kern);
 ssize_t vringh_iov_push_kern(struct vringh_kiov *wiov,
 			     const void *src, size_t len)
 {
-	return vringh_iov_xfer(wiov, (void *)src, len, xfer_kern);
+	return vringh_iov_xfer(wiov, (void *)src, len, kern_xfer);
 }
 EXPORT_SYMBOL(vringh_iov_push_kern);
 
Signature · 1 line
2.19.1
author
#3 lore raw
Quoted 9 lines · Michael S. Tsirkin
Quoted 6 lines · Jason Wang

We want to copy from iov to buf, so the direction was wrong.

Note: no real user for the helper, but it will be used by future features.

I'm still inclined to merge it now, incorrect code tends to proliferate.

I'm fine with this, so I believe you will merge this patch?

Thanks

Quoted 31 lines
Quoted 31 lines
---
  drivers/vhost/vringh.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/vhost/vringh.c +7 -1
index 08ad0d1f0476..a0a2d74967ef 100644
@@ -852,6 +852,12 @@ static inline int xfer_kern(void *src, void *dst, size_t len)
  	return 0;
  }
 
+static inline int kern_xfer(void *dst, void *src, size_t len)
+{
+	memcpy(dst, src, len);
+	return 0;
+}
+
  /**
   * vringh_init_kern - initialize a vringh for a kernelspace vring.
   * @vrh: the vringh to initialize.
@@ -958,7 +964,7 @@ EXPORT_SYMBOL(vringh_iov_pull_kern);
  ssize_t vringh_iov_push_kern(struct vringh_kiov *wiov,
  			     const void *src, size_t len)
  {
-	return vringh_iov_xfer(wiov, (void *)src, len, xfer_kern);
+	return vringh_iov_xfer(wiov, (void *)src, len, kern_xfer);
  }
  EXPORT_SYMBOL(vringh_iov_push_kern);
 
Quoted 2 lines
Quoted 2 lines
Signature · 1 line
2.19.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#4 lore raw
In reply to Michael S. Tsirkin
Quoted 9 lines · Michael S. Tsirkin
Quoted 6 lines · Jason Wang

We want to copy from iov to buf, so the direction was wrong.

Note: no real user for the helper, but it will be used by future features.

I'm still inclined to merge it now, incorrect code tends to proliferate.

I'm fine with this, so I believe you will merge this patch?

Thanks

Quoted 33 lines
Quoted 33 lines
---
  drivers/vhost/vringh.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/vhost/vringh.c +7 -1
index 08ad0d1f0476..a0a2d74967ef 100644
@@ -852,6 +852,12 @@ static inline int xfer_kern(void *src, void *dst, size_t len)
  	return 0;
  }
 
+static inline int kern_xfer(void *dst, void *src, size_t len)
+{
+	memcpy(dst, src, len);
+	return 0;
+}
+
  /**
   * vringh_init_kern - initialize a vringh for a kernelspace vring.
   * @vrh: the vringh to initialize.
@@ -958,7 +964,7 @@ EXPORT_SYMBOL(vringh_iov_pull_kern);
  ssize_t vringh_iov_push_kern(struct vringh_kiov *wiov,
  			     const void *src, size_t len)
  {
-	return vringh_iov_xfer(wiov, (void *)src, len, xfer_kern);
+	return vringh_iov_xfer(wiov, (void *)src, len, kern_xfer);
  }
  EXPORT_SYMBOL(vringh_iov_push_kern);
 
Signature · 1 line
2.19.1