Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
fd99beb9
Commit
fd99beb9
authored
Jul 19, 2011
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'vhost-net-next' of
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
parents
3fbcf6bb
b834226b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
33 deletions
+64
-33
drivers/vhost/net.c
drivers/vhost/net.c
+4
-0
drivers/vhost/test.c
drivers/vhost/test.c
+5
-0
drivers/vhost/vhost.c
drivers/vhost/vhost.c
+54
-33
drivers/vhost/vhost.h
drivers/vhost/vhost.h
+1
-0
No files found.
drivers/vhost/net.c
View file @
fd99beb9
...
@@ -703,6 +703,10 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
...
@@ -703,6 +703,10 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
vhost_net_disable_vq
(
n
,
vq
);
vhost_net_disable_vq
(
n
,
vq
);
rcu_assign_pointer
(
vq
->
private_data
,
sock
);
rcu_assign_pointer
(
vq
->
private_data
,
sock
);
vhost_net_enable_vq
(
n
,
vq
);
vhost_net_enable_vq
(
n
,
vq
);
r
=
vhost_init_used
(
vq
);
if
(
r
)
goto
err_vq
;
}
}
mutex_unlock
(
&
vq
->
mutex
);
mutex_unlock
(
&
vq
->
mutex
);
...
...
drivers/vhost/test.c
View file @
fd99beb9
...
@@ -195,8 +195,13 @@ static long vhost_test_run(struct vhost_test *n, int test)
...
@@ -195,8 +195,13 @@ static long vhost_test_run(struct vhost_test *n, int test)
lockdep_is_held
(
&
vq
->
mutex
));
lockdep_is_held
(
&
vq
->
mutex
));
rcu_assign_pointer
(
vq
->
private_data
,
priv
);
rcu_assign_pointer
(
vq
->
private_data
,
priv
);
r
=
vhost_init_used
(
&
n
->
vqs
[
index
]);
mutex_unlock
(
&
vq
->
mutex
);
mutex_unlock
(
&
vq
->
mutex
);
if
(
r
)
goto
err
;
if
(
oldpriv
)
{
if
(
oldpriv
)
{
vhost_test_flush_vq
(
n
,
index
);
vhost_test_flush_vq
(
n
,
index
);
}
}
...
...
drivers/vhost/vhost.c
View file @
fd99beb9
...
@@ -629,17 +629,6 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
...
@@ -629,17 +629,6 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
return
0
;
return
0
;
}
}
static
int
init_used
(
struct
vhost_virtqueue
*
vq
,
struct
vring_used
__user
*
used
)
{
int
r
=
put_user
(
vq
->
used_flags
,
&
used
->
flags
);
if
(
r
)
return
r
;
vq
->
signalled_used_valid
=
false
;
return
get_user
(
vq
->
last_used_idx
,
&
used
->
idx
);
}
static
long
vhost_set_vring
(
struct
vhost_dev
*
d
,
int
ioctl
,
void
__user
*
argp
)
static
long
vhost_set_vring
(
struct
vhost_dev
*
d
,
int
ioctl
,
void
__user
*
argp
)
{
{
struct
file
*
eventfp
,
*
filep
=
NULL
,
struct
file
*
eventfp
,
*
filep
=
NULL
,
...
@@ -752,10 +741,6 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
...
@@ -752,10 +741,6 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
}
}
}
}
r
=
init_used
(
vq
,
(
struct
vring_used
__user
*
)(
unsigned
long
)
a
.
used_user_addr
);
if
(
r
)
break
;
vq
->
log_used
=
!!
(
a
.
flags
&
(
0x1
<<
VHOST_VRING_F_LOG
));
vq
->
log_used
=
!!
(
a
.
flags
&
(
0x1
<<
VHOST_VRING_F_LOG
));
vq
->
desc
=
(
void
__user
*
)(
unsigned
long
)
a
.
desc_user_addr
;
vq
->
desc
=
(
void
__user
*
)(
unsigned
long
)
a
.
desc_user_addr
;
vq
->
avail
=
(
void
__user
*
)(
unsigned
long
)
a
.
avail_user_addr
;
vq
->
avail
=
(
void
__user
*
)(
unsigned
long
)
a
.
avail_user_addr
;
...
@@ -1010,6 +995,57 @@ int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
...
@@ -1010,6 +995,57 @@ int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
return
0
;
return
0
;
}
}
static
int
vhost_update_used_flags
(
struct
vhost_virtqueue
*
vq
)
{
void
__user
*
used
;
if
(
__put_user
(
vq
->
used_flags
,
&
vq
->
used
->
flags
)
<
0
)
return
-
EFAULT
;
if
(
unlikely
(
vq
->
log_used
))
{
/* Make sure the flag is seen before log. */
smp_wmb
();
/* Log used flag write. */
used
=
&
vq
->
used
->
flags
;
log_write
(
vq
->
log_base
,
vq
->
log_addr
+
(
used
-
(
void
__user
*
)
vq
->
used
),
sizeof
vq
->
used
->
flags
);
if
(
vq
->
log_ctx
)
eventfd_signal
(
vq
->
log_ctx
,
1
);
}
return
0
;
}
static
int
vhost_update_avail_event
(
struct
vhost_virtqueue
*
vq
,
u16
avail_event
)
{
if
(
__put_user
(
vq
->
avail_idx
,
vhost_avail_event
(
vq
)))
return
-
EFAULT
;
if
(
unlikely
(
vq
->
log_used
))
{
void
__user
*
used
;
/* Make sure the event is seen before log. */
smp_wmb
();
/* Log avail event write */
used
=
vhost_avail_event
(
vq
);
log_write
(
vq
->
log_base
,
vq
->
log_addr
+
(
used
-
(
void
__user
*
)
vq
->
used
),
sizeof
*
vhost_avail_event
(
vq
));
if
(
vq
->
log_ctx
)
eventfd_signal
(
vq
->
log_ctx
,
1
);
}
return
0
;
}
int
vhost_init_used
(
struct
vhost_virtqueue
*
vq
)
{
int
r
;
if
(
!
vq
->
private_data
)
return
0
;
r
=
vhost_update_used_flags
(
vq
);
if
(
r
)
return
r
;
vq
->
signalled_used_valid
=
false
;
return
get_user
(
vq
->
last_used_idx
,
&
vq
->
used
->
idx
);
}
static
int
translate_desc
(
struct
vhost_dev
*
dev
,
u64
addr
,
u32
len
,
static
int
translate_desc
(
struct
vhost_dev
*
dev
,
u64
addr
,
u32
len
,
struct
iovec
iov
[],
int
iov_size
)
struct
iovec
iov
[],
int
iov_size
)
{
{
...
@@ -1481,34 +1517,20 @@ bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
...
@@ -1481,34 +1517,20 @@ bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
return
false
;
return
false
;
vq
->
used_flags
&=
~
VRING_USED_F_NO_NOTIFY
;
vq
->
used_flags
&=
~
VRING_USED_F_NO_NOTIFY
;
if
(
!
vhost_has_feature
(
dev
,
VIRTIO_RING_F_EVENT_IDX
))
{
if
(
!
vhost_has_feature
(
dev
,
VIRTIO_RING_F_EVENT_IDX
))
{
r
=
put_user
(
vq
->
used_flags
,
&
vq
->
used
->
flags
);
r
=
vhost_update_used_flags
(
vq
);
if
(
r
)
{
if
(
r
)
{
vq_err
(
vq
,
"Failed to enable notification at %p: %d
\n
"
,
vq_err
(
vq
,
"Failed to enable notification at %p: %d
\n
"
,
&
vq
->
used
->
flags
,
r
);
&
vq
->
used
->
flags
,
r
);
return
false
;
return
false
;
}
}
}
else
{
}
else
{
r
=
put_user
(
vq
->
avail_idx
,
vhost_avail_event
(
vq
)
);
r
=
vhost_update_avail_event
(
vq
,
vq
->
avail_idx
);
if
(
r
)
{
if
(
r
)
{
vq_err
(
vq
,
"Failed to update avail event index at %p: %d
\n
"
,
vq_err
(
vq
,
"Failed to update avail event index at %p: %d
\n
"
,
vhost_avail_event
(
vq
),
r
);
vhost_avail_event
(
vq
),
r
);
return
false
;
return
false
;
}
}
}
}
if
(
unlikely
(
vq
->
log_used
))
{
void
__user
*
used
;
/* Make sure data is seen before log. */
smp_wmb
();
used
=
vhost_has_feature
(
dev
,
VIRTIO_RING_F_EVENT_IDX
)
?
&
vq
->
used
->
flags
:
vhost_avail_event
(
vq
);
/* Log used flags or event index entry write. Both are 16 bit
* fields. */
log_write
(
vq
->
log_base
,
vq
->
log_addr
+
(
used
-
(
void
__user
*
)
vq
->
used
),
sizeof
(
u16
));
if
(
vq
->
log_ctx
)
eventfd_signal
(
vq
->
log_ctx
,
1
);
}
/* They could have slipped one in as we were doing that: make
/* They could have slipped one in as we were doing that: make
* sure it's written, then check again. */
* sure it's written, then check again. */
smp_mb
();
smp_mb
();
...
@@ -1531,7 +1553,7 @@ void vhost_disable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
...
@@ -1531,7 +1553,7 @@ void vhost_disable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
return
;
return
;
vq
->
used_flags
|=
VRING_USED_F_NO_NOTIFY
;
vq
->
used_flags
|=
VRING_USED_F_NO_NOTIFY
;
if
(
!
vhost_has_feature
(
dev
,
VIRTIO_RING_F_EVENT_IDX
))
{
if
(
!
vhost_has_feature
(
dev
,
VIRTIO_RING_F_EVENT_IDX
))
{
r
=
put_user
(
vq
->
used_flags
,
&
vq
->
used
->
flags
);
r
=
vhost_update_used_flags
(
vq
);
if
(
r
)
if
(
r
)
vq_err
(
vq
,
"Failed to enable notification at %p: %d
\n
"
,
vq_err
(
vq
,
"Failed to enable notification at %p: %d
\n
"
,
&
vq
->
used
->
flags
,
r
);
&
vq
->
used
->
flags
,
r
);
...
@@ -1556,7 +1578,6 @@ struct vhost_ubuf_ref *vhost_ubuf_alloc(struct vhost_virtqueue *vq,
...
@@ -1556,7 +1578,6 @@ struct vhost_ubuf_ref *vhost_ubuf_alloc(struct vhost_virtqueue *vq,
if
(
!
ubufs
)
if
(
!
ubufs
)
return
ERR_PTR
(
-
ENOMEM
);
return
ERR_PTR
(
-
ENOMEM
);
kref_init
(
&
ubufs
->
kref
);
kref_init
(
&
ubufs
->
kref
);
kref_get
(
&
ubufs
->
kref
);
init_waitqueue_head
(
&
ubufs
->
wait
);
init_waitqueue_head
(
&
ubufs
->
wait
);
ubufs
->
vq
=
vq
;
ubufs
->
vq
=
vq
;
return
ubufs
;
return
ubufs
;
...
...
drivers/vhost/vhost.h
View file @
fd99beb9
...
@@ -174,6 +174,7 @@ int vhost_get_vq_desc(struct vhost_dev *, struct vhost_virtqueue *,
...
@@ -174,6 +174,7 @@ int vhost_get_vq_desc(struct vhost_dev *, struct vhost_virtqueue *,
struct
vhost_log
*
log
,
unsigned
int
*
log_num
);
struct
vhost_log
*
log
,
unsigned
int
*
log_num
);
void
vhost_discard_vq_desc
(
struct
vhost_virtqueue
*
,
int
n
);
void
vhost_discard_vq_desc
(
struct
vhost_virtqueue
*
,
int
n
);
int
vhost_init_used
(
struct
vhost_virtqueue
*
);
int
vhost_add_used
(
struct
vhost_virtqueue
*
,
unsigned
int
head
,
int
len
);
int
vhost_add_used
(
struct
vhost_virtqueue
*
,
unsigned
int
head
,
int
len
);
int
vhost_add_used_n
(
struct
vhost_virtqueue
*
,
struct
vring_used_elem
*
heads
,
int
vhost_add_used_n
(
struct
vhost_virtqueue
*
,
struct
vring_used_elem
*
heads
,
unsigned
count
);
unsigned
count
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment