login
Login
/
Register
Search
Header Space
Forums
News
Jobs
Blogs
Features
Man Pages
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
April
»
19
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuffer interface.
view
thread
Score:
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From:
Evgeniy Polyakov <johnpol@...>
To: Rusty Russell <rusty@...>
Cc: <netdev@...>, Max Krasnyansky <maxk@...>, <virtualization@...>, <linux-kernel@...>
Subject:
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuffer interface.
Date: Saturday, April 19, 2008 - 6:22 am
Hi. On Fri, Apr 18, 2008 at 02:39:48PM +1000, Rusty Russell (
rusty@rustcorp.com.au
) wrote:
quoted text
> +int vring_get_buffer(struct vring_info *vr, > + struct iovec *in_iov, > + unsigned int *num_in, unsigned long *in_len, > + struct iovec *out_iov, > + unsigned int *num_out, unsigned long *out_len) > +{ > + unsigned int i, in = 0, out = 0; > + unsigned long dummy; > + u16 avail, last_avail, head; > + struct vring_desc d;
Should this whole function and vring_used_buffer() be protected with vr->lock mutex?
quoted text
> + if (unlikely(get_user(avail, &vr->ring.avail->idx))) > + return -EFAULT; > + if (unlikely(get_user(last_avail, &vring_last_avail(&vr->ring)))) > + return -EFAULT; > + > + if (last_avail == avail) > + return 0; > + > + if (!in_len) > + in_len = &dummy; > + if (!out_len) > + out_len = &dummy; > + > + *in_len = *out_len = 0; > + > + if (unlikely(get_user(head, &vr->ring.avail->ring[last_avail > + & vr->mask]))) > + return -EFAULT; > + > + i = head; > + do { > + if (unlikely(i >= vr->ring.num)) { > + pr_debug("vring: bad index: %u\n", i); > + return -EINVAL; > + } > + > + if (copy_from_user(&d, &vr->ring.desc[i], sizeof(d)) != 0) > + return -EFAULT; > + > + if (d.flags & VRING_DESC_F_WRITE) { > + /* Check for length and iovec overflows */ > + if (!num_in) { > + pr_debug("vring: writable desc %u in ring %p\n", > + i, vr->ring.desc); > + return -EINVAL; > + } > + if (in == *num_in || *in_len + d.len < *in_len) > + return -E2BIG; > + in_iov[in].iov_len = d.len; > + *in_len += d.len; > + in_iov[in].iov_base = (void __user *)(long)d.addr; > + in++; > + } else { > + if (!num_out) { > + pr_debug("vring: readable desc %u in ring %p\n", > + i, vr->ring.desc); > + return -EINVAL; > + } > + if (out == *num_out || *out_len + d.len < *out_len) > + return -E2BIG; > + out_iov[out].iov_len = d.len; > + *out_len += d.len; > + out_iov[out].iov_base = (void __user *)(long)d.addr; > + out++; > + } > + > + i = d.next; > + } while (d.flags & VRING_DESC_F_NEXT); > + > + if (num_in) > + *num_in = in; > + if (num_out) > + *num_out = out; > + > + last_avail++; > + put_user(last_avail, &vring_last_avail(&vr->ring)); > + > + /* 0 is a valid head, so add one. */ > + return head + 1; > +} > +EXPORT_SYMBOL_GPL(vring_get_buffer); > + > +/** > + * vring_used_buffer - return a used buffer to the vring > + * @vr: the vring > + * @id: the id returned from vring_get_buffer > + * @len: the total bytes *written* to the buffer > + */ > +void vring_used_buffer(struct vring_info *vr, int id, u32 len) > +{ > + struct vring_used_elem used; > + u16 used_idx; > + > + BUG_ON(id <= 0 || id > vr->ring.num); > + > + used.id = id - 1; > + used.len = len; > + if (get_user(used_idx, &vr->ring.used->idx) != 0) > + return; > + > + if (copy_to_user(&vr->ring.used->ring[used_idx & vr->mask], &used, > + sizeof(used))) > + return; > + > + wmb(); > + used_idx++; > + put_user(used_idx, &vr->ring.used->idx); > +} > +EXPORT_SYMBOL_GPL(vring_used_buffer);
-- Evgeniy Polyakov --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH 0/5] High-speed tun receive and xmit
, Rusty Russell
, (Fri Apr 18, 12:33 am)
[PATCH 1/5] virtio: put last_used and last_avail index into ...
, Rusty Russell
, (Fri Apr 18, 12:35 am)
[PATCH 2/5] /dev/vring: simple userspace-kernel ringbuffer i...
, Rusty Russell
, (Fri Apr 18, 12:39 am)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Evgeniy Polyakov
, (Sat Apr 19, 6:22 am)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Rusty Russell
, (Sat Apr 19, 12:05 pm)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Evgeniy Polyakov
, (Sat Apr 19, 12:33 pm)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Rusty Russell
, (Sat Apr 19, 12:45 pm)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Andrew Morton
, (Fri Apr 18, 7:18 am)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Rusty Russell
, (Fri Apr 18, 10:32 am)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Andrew Morton
, (Fri Apr 18, 2:59 pm)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Jonathan Corbet
, (Sat Apr 19, 11:02 am)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Michael Kerrisk
, (Fri Apr 18, 3:38 pm)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, Rusty Russell
, (Sat Apr 19, 12:41 pm)
Re: [PATCH 2/5] /dev/vring: simple userspace-kernel ringbuff...
, David Miller
, (Sat Apr 19, 8:16 pm)
[PATCH 3/5] /dev/vring limit and base ioctls
, Rusty Russell
, (Fri Apr 18, 12:41 am)
[PATCH 4/5] tun: vringfd receive support.
, Rusty Russell
, (Fri Apr 18, 12:42 am)
[PATCH 5/5] tun: vringfd xmit support.
, Rusty Russell
, (Fri Apr 18, 12:43 am)
Re: [PATCH 5/5] tun: vringfd xmit support.
, pradeep singh rautela
, (Fri Apr 18, 7:46 am)
Re: [PATCH 5/5] tun: vringfd xmit support.
, Ray Lee
, (Fri Apr 18, 10:25 am)
Re: [PATCH 5/5] tun: vringfd xmit support.
, pradeep singh rautela
, (Fri Apr 18, 2:01 pm)
Re: [PATCH 5/5] tun: vringfd xmit support.
, Andrew Morton
, (Fri Apr 18, 7:31 am)
Re: [PATCH 5/5] tun: vringfd xmit support.
, Rusty Russell
, (Fri Apr 18, 11:15 am)
Re: [PATCH 5/5] tun: vringfd xmit support.
, Andrew Morton
, (Fri Apr 18, 9:54 pm)
Re: [PATCH 5/5] tun: vringfd xmit support.
, Andrew Morton
, (Fri Apr 18, 3:06 pm)
Re: [PATCH 5/5] tun: vringfd xmit support.
, Rusty Russell
, (Sat Apr 19, 10:41 am)
Re: [PATCH 5/5] tun: vringfd xmit support.
, Andrew Morton
, (Sat Apr 19, 1:51 pm)
Re: [PATCH 5/5] tun: vringfd xmit support.
, Ray Lee
, (Fri Apr 18, 12:24 pm)
Navigation
Create content
Mailing list archives
Recent posts
Mail archive search
Enter your search terms.
all mailing lists
alsa-devel
dragonflybsd-bugs
dragonflybsd-commit
dragonflybsd-docs
dragonflybsd-kernel
dragonflybsd-submit
dragonflybsd-user
freebsd-announce
freebsd-bugs
freebsd-chat
freebsd-cluster
freebsd-current
freebsd-drivers
freebsd-embeded
freebsd-fs
freebsd-hackers
freebsd-hardware
freebsd-mobile
freebsd-net
freebsd-performance
freebsd-pf
freebsd-security
freebsd-security-notifications
freebsd-threads
git
git-commits-head
linux-activists
linux-arm
linux-ath5k-devel
linux-btrfs
linux-c-programming
linux-driver-devel
linux-ext4
linux-fsdevel
linux-ia64
linux-input
linux-kernel
linux-kernel-janitors
linux-kernel-mentors
linux-kernel-newbies
linux-kvm
linux-net
linux-netdev
linux-newbie
linux-nfs
linux-raid
linux-scsi
linux-security-module
linux-sparse
linux-usb
linux-usb-devel
madwifi-devel
netbsd-announce
netbsd-tech-kern
openbsd-announce
openbsd-bugs
openbsd-ipv6
openbsd-misc
openbsd-security-announce
openbsd-smp
openbsd-source-changes
openbsd-tech
openfabrics-general
openmoko-community
openmoko-devel
openmoko-kernel
reiserfs-devel
tux3
ucarp
Optionally limit your search to a specific mailing list.
advanced
Popular discussions
linux-kernel
:
Ryan Hope
reiser4 for 2.6.27-rc1
hooanon05
[PATCH 63/67] aufs mount helper
Rafael J. Wysocki
2.6.26-rc9-git12: Reported regressions from 2.6.25
Peter Zijlstra
Re: [ANNOUNCE] mdb: Merkey's Linux Kernel Debugger 2.6.27-rc4 released
git
:
Ken Pratt
pack operation is thrashing my server
しらいしななこ
[PATCH] Update Japanese translation
Christian Couder
[PATCH] Documentation: help: explain 'man.viewer' multiple values
Dennis Schridde
Odd number of elements in anonymous hash
openbsd-misc
:
GVG GVG
ssh_exchange_identification: Connection closed by remote host
Chris
avoid logging useless ssh brute force attempts
Ray Percival
Re: Real men don't attack straw men
Marius ROMAN
1440x900 resolution problem
linux-activists
:
Jim Winstead Jr.
Re: Root Disk/Book Disk Compatibility
Doug Evans
Re: Stabilizing Linux
Stephen Pierce
SLS
Mark Evans
Re: Possible bug in TCP/IP stuff of kernel (0.99p5 on up).
Latest forum posts
trouble with my Asus Mainboard
3 hours ago
Linux kernel
what is "callback function"?.can anyone explain me please..
1 day ago
Linux general
unable to remove block device driver module
1 day ago
Linux kernel
Is there anything like Real-time drivers?
2 days ago
Linux general
I can't allocate more than 4 MB with pci_alloc_consistent
2 days ago
Linux kernel
Resetting the bios password for Toshiba Laptop
2 days ago
Hardware
Kernel panic while installing fedora core 5 or ubuntu
3 days ago
Hardware
Interactive Linux kernel map
3 days ago
Linux kernel
unable to add a variable in buffer_head struct
3 days ago
Linux kernel
Linux Input driver - setting scaling/resolution on USB mouse
4 days ago
Linux kernel
Show all forums...
Recent Tags
Linux
Rik van Riel
-rc
git 1.6
Junio Hamano
quote
2.6.27
GCC
Linus Torvalds
Ingo Molnar
release
filesystem
git 1.6.0
AXFS
git
cramfs
performance
squashfs
Jared Hulbert
Andrew Morton
more tags
Colocation donated by:
Who's online
There are currently
4 users
and
854 guests
online.
Online users
Jeremy
strcmp
mmessano
espenfjo
Syndicate
speck-geostationary