projects
/
lttng-modules.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: update v4l2 instrumentation to 3.15 kernel
[lttng-modules.git]
/
lib
/
ringbuffer
/
backend.h
diff --git
a/lib/ringbuffer/backend.h
b/lib/ringbuffer/backend.h
index 2ce6ce9cd752508484123d4997d0f18481913b85..bbbc80d8eb03be444d4890d828d92f7f6eb118ab 100644
(file)
--- a/
lib/ringbuffer/backend.h
+++ b/
lib/ringbuffer/backend.h
@@
-34,6
+34,7
@@
#include <linux/list.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/list.h>
#include <linux/fs.h>
#include <linux/mm.h>
+#include <linux/uaccess.h>
/* Internal helpers */
#include "../../wrapper/ringbuffer/backend_internal.h"
/* Internal helpers */
#include "../../wrapper/ringbuffer/backend_internal.h"
@@
-95,6
+96,8
@@
void lib_ring_buffer_write(const struct lib_ring_buffer_config *config,
struct lib_ring_buffer_backend_pages *rpages;
unsigned long sb_bindex, id;
struct lib_ring_buffer_backend_pages *rpages;
unsigned long sb_bindex, id;
+ if (unlikely(!len))
+ return;
offset &= chanb->buf_size - 1;
sbidx = offset >> chanb->subbuf_size_order;
index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
offset &= chanb->buf_size - 1;
sbidx = offset >> chanb->subbuf_size_order;
index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
@@
-141,6
+144,8
@@
void lib_ring_buffer_memset(const struct lib_ring_buffer_config *config,
struct lib_ring_buffer_backend_pages *rpages;
unsigned long sb_bindex, id;
struct lib_ring_buffer_backend_pages *rpages;
unsigned long sb_bindex, id;
+ if (unlikely(!len))
+ return;
offset &= chanb->buf_size - 1;
sbidx = offset >> chanb->subbuf_size_order;
index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
offset &= chanb->buf_size - 1;
sbidx = offset >> chanb->subbuf_size_order;
index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
@@
-161,7
+166,7
@@
void lib_ring_buffer_memset(const struct lib_ring_buffer_config *config,
}
/**
}
/**
- * lib_ring_buffer_copy_from_user - write userspace data to a buffer backend
+ * lib_ring_buffer_copy_from_user
_inatomic
- write userspace data to a buffer backend
* @config : ring buffer instance configuration
* @ctx: ring buffer context. (input arguments only)
* @src : userspace source pointer to copy from
* @config : ring buffer instance configuration
* @ctx: ring buffer context. (input arguments only)
* @src : userspace source pointer to copy from
@@
-170,10
+175,11
@@
void lib_ring_buffer_memset(const struct lib_ring_buffer_config *config,
* This function copies "len" bytes of data from a userspace pointer to a
* buffer backend, at the current context offset. This is more or less a buffer
* backend-specific memcpy() operation. Calls the slow path
* This function copies "len" bytes of data from a userspace pointer to a
* buffer backend, at the current context offset. This is more or less a buffer
* backend-specific memcpy() operation. Calls the slow path
- * (_ring_buffer_write_from_user) if copy is crossing a page boundary.
+ * (_ring_buffer_write_from_user_inatomic) if copy is crossing a page boundary.
+ * Disable the page fault handler to ensure we never try to take the mmap_sem.
*/
static inline
*/
static inline
-void lib_ring_buffer_copy_from_user(const struct lib_ring_buffer_config *config,
+void lib_ring_buffer_copy_from_user
_inatomic
(const struct lib_ring_buffer_config *config,
struct lib_ring_buffer_ctx *ctx,
const void __user *src, size_t len)
{
struct lib_ring_buffer_ctx *ctx,
const void __user *src, size_t len)
{
@@
-185,7
+191,10
@@
void lib_ring_buffer_copy_from_user(const struct lib_ring_buffer_config *config,
struct lib_ring_buffer_backend_pages *rpages;
unsigned long sb_bindex, id;
unsigned long ret;
struct lib_ring_buffer_backend_pages *rpages;
unsigned long sb_bindex, id;
unsigned long ret;
+ mm_segment_t old_fs = get_fs();
+ if (unlikely(!len))
+ return;
offset &= chanb->buf_size - 1;
sbidx = offset >> chanb->subbuf_size_order;
index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
offset &= chanb->buf_size - 1;
sbidx = offset >> chanb->subbuf_size_order;
index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
@@
-197,11
+206,13
@@
void lib_ring_buffer_copy_from_user(const struct lib_ring_buffer_config *config,
config->mode == RING_BUFFER_OVERWRITE
&& subbuffer_id_is_noref(config, id));
config->mode == RING_BUFFER_OVERWRITE
&& subbuffer_id_is_noref(config, id));
+ set_fs(KERNEL_DS);
+ pagefault_disable();
if (unlikely(!access_ok(VERIFY_READ, src, len)))
goto fill_buffer;
if (likely(pagecpy == len)) {
if (unlikely(!access_ok(VERIFY_READ, src, len)))
goto fill_buffer;
if (likely(pagecpy == len)) {
- ret = lib_ring_buffer_do_copy_from_user(
+ ret = lib_ring_buffer_do_copy_from_user
_inatomic
(
rpages->p[index].virt + (offset & ~PAGE_MASK),
src, len);
if (unlikely(ret > 0)) {
rpages->p[index].virt + (offset & ~PAGE_MASK),
src, len);
if (unlikely(ret > 0)) {
@@
-210,13
+221,17
@@
void lib_ring_buffer_copy_from_user(const struct lib_ring_buffer_config *config,
goto fill_buffer;
}
} else {
goto fill_buffer;
}
} else {
- _lib_ring_buffer_copy_from_user(bufb, offset, src, len, 0);
+ _lib_ring_buffer_copy_from_user
_inatomic
(bufb, offset, src, len, 0);
}
}
+ pagefault_enable();
+ set_fs(old_fs);
ctx->buf_offset += len;
return;
fill_buffer:
ctx->buf_offset += len;
return;
fill_buffer:
+ pagefault_enable();
+ set_fs(old_fs);
/*
* In the error path we call the slow path version to avoid
* the pollution of static inline code.
/*
* In the error path we call the slow path version to avoid
* the pollution of static inline code.
@@
-254,9
+269,4
@@
unsigned long lib_ring_buffer_get_records_unread(
return records_unread;
}
return records_unread;
}
-ssize_t lib_ring_buffer_file_splice_read(struct file *in, loff_t *ppos,
- struct pipe_inode_info *pipe,
- size_t len, unsigned int flags);
-loff_t lib_ring_buffer_no_llseek(struct file *file, loff_t offset, int origin);
-
#endif /* _LIB_RING_BUFFER_BACKEND_H */
#endif /* _LIB_RING_BUFFER_BACKEND_H */
This page took
0.025579 seconds
and
4
git commands to generate.