Commit 76484b1c authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Linus Torvalds

kcov: move t->kcov assignments into kcov_start/stop

Every time kcov_start/stop() is called, t->kcov is also assigned, so move
the assignment into the functions.
Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Alexander Potapenko <glider@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Marco Elver <elver@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Link: http://lkml.kernel.org/r/6644839d3567df61ade3c4b246a46cacbe4f9e11.1585233617.git.andreyknvl@google.com
Link: http://lkml.kernel.org/r/82625ef3ff878f0b585763cc31d09d9b08ca37d6.1584655448.git.andreyknvl@google.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 67b3d3cc
...@@ -309,10 +309,12 @@ void notrace __sanitizer_cov_trace_switch(u64 val, u64 *cases) ...@@ -309,10 +309,12 @@ void notrace __sanitizer_cov_trace_switch(u64 val, u64 *cases)
EXPORT_SYMBOL(__sanitizer_cov_trace_switch); EXPORT_SYMBOL(__sanitizer_cov_trace_switch);
#endif /* ifdef CONFIG_KCOV_ENABLE_COMPARISONS */ #endif /* ifdef CONFIG_KCOV_ENABLE_COMPARISONS */
static void kcov_start(struct task_struct *t, unsigned int size, static void kcov_start(struct task_struct *t, struct kcov *kcov,
void *area, enum kcov_mode mode, int sequence) unsigned int size, void *area, enum kcov_mode mode,
int sequence)
{ {
kcov_debug("t = %px, size = %u, area = %px\n", t, size, area); kcov_debug("t = %px, size = %u, area = %px\n", t, size, area);
t->kcov = kcov;
/* Cache in task struct for performance. */ /* Cache in task struct for performance. */
t->kcov_size = size; t->kcov_size = size;
t->kcov_area = area; t->kcov_area = area;
...@@ -326,6 +328,7 @@ static void kcov_stop(struct task_struct *t) ...@@ -326,6 +328,7 @@ static void kcov_stop(struct task_struct *t)
{ {
WRITE_ONCE(t->kcov_mode, KCOV_MODE_DISABLED); WRITE_ONCE(t->kcov_mode, KCOV_MODE_DISABLED);
barrier(); barrier();
t->kcov = NULL;
t->kcov_size = 0; t->kcov_size = 0;
t->kcov_area = NULL; t->kcov_area = NULL;
} }
...@@ -333,7 +336,6 @@ static void kcov_stop(struct task_struct *t) ...@@ -333,7 +336,6 @@ static void kcov_stop(struct task_struct *t)
static void kcov_task_reset(struct task_struct *t) static void kcov_task_reset(struct task_struct *t)
{ {
kcov_stop(t); kcov_stop(t);
t->kcov = NULL;
t->kcov_sequence = 0; t->kcov_sequence = 0;
t->kcov_handle = 0; t->kcov_handle = 0;
} }
...@@ -584,9 +586,8 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd, ...@@ -584,9 +586,8 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd,
return mode; return mode;
kcov_fault_in_area(kcov); kcov_fault_in_area(kcov);
kcov->mode = mode; kcov->mode = mode;
kcov_start(t, kcov->size, kcov->area, kcov->mode, kcov_start(t, kcov, kcov->size, kcov->area, kcov->mode,
kcov->sequence); kcov->sequence);
t->kcov = kcov;
kcov->t = t; kcov->t = t;
/* Put either in kcov_task_exit() or in KCOV_DISABLE. */ /* Put either in kcov_task_exit() or in KCOV_DISABLE. */
kcov_get(kcov); kcov_get(kcov);
...@@ -778,7 +779,6 @@ void kcov_remote_start(u64 handle) ...@@ -778,7 +779,6 @@ void kcov_remote_start(u64 handle)
kcov = remote->kcov; kcov = remote->kcov;
/* Put in kcov_remote_stop(). */ /* Put in kcov_remote_stop(). */
kcov_get(kcov); kcov_get(kcov);
t->kcov = kcov;
/* /*
* Read kcov fields before unlock to prevent races with * Read kcov fields before unlock to prevent races with
* KCOV_DISABLE / kcov_remote_reset(). * KCOV_DISABLE / kcov_remote_reset().
...@@ -792,7 +792,6 @@ void kcov_remote_start(u64 handle) ...@@ -792,7 +792,6 @@ void kcov_remote_start(u64 handle)
if (!area) { if (!area) {
area = vmalloc(size * sizeof(unsigned long)); area = vmalloc(size * sizeof(unsigned long));
if (!area) { if (!area) {
t->kcov = NULL;
kcov_put(kcov); kcov_put(kcov);
return; return;
} }
...@@ -800,7 +799,7 @@ void kcov_remote_start(u64 handle) ...@@ -800,7 +799,7 @@ void kcov_remote_start(u64 handle)
/* Reset coverage size. */ /* Reset coverage size. */
*(u64 *)area = 0; *(u64 *)area = 0;
kcov_start(t, size, area, mode, sequence); kcov_start(t, kcov, size, area, mode, sequence);
} }
EXPORT_SYMBOL(kcov_remote_start); EXPORT_SYMBOL(kcov_remote_start);
...@@ -873,7 +872,6 @@ void kcov_remote_stop(void) ...@@ -873,7 +872,6 @@ void kcov_remote_stop(void)
return; return;
kcov_stop(t); kcov_stop(t);
t->kcov = NULL;
spin_lock(&kcov->lock); spin_lock(&kcov->lock);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment