Commit 55a55fec authored by Marco Elver's avatar Marco Elver Committed by Paul E. McKenney

kcsan: Add ability to pass instruction pointer of access to reporting

Add the ability to pass an explicitly set instruction pointer of access
from check_access() all the way through to reporting.

In preparation of using it in reporting.
Signed-off-by: default avatarMarco Elver <elver@google.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent ade3a58b
This diff is collapsed.
...@@ -121,7 +121,7 @@ enum kcsan_value_change { ...@@ -121,7 +121,7 @@ enum kcsan_value_change {
* to be consumed by the reporting thread. No report is printed yet. * to be consumed by the reporting thread. No report is printed yet.
*/ */
void kcsan_report_set_info(const volatile void *ptr, size_t size, int access_type, void kcsan_report_set_info(const volatile void *ptr, size_t size, int access_type,
int watchpoint_idx); unsigned long ip, int watchpoint_idx);
/* /*
* The calling thread observed that the watchpoint it set up was hit and * The calling thread observed that the watchpoint it set up was hit and
...@@ -129,14 +129,14 @@ void kcsan_report_set_info(const volatile void *ptr, size_t size, int access_typ ...@@ -129,14 +129,14 @@ void kcsan_report_set_info(const volatile void *ptr, size_t size, int access_typ
* thread. * thread.
*/ */
void kcsan_report_known_origin(const volatile void *ptr, size_t size, int access_type, void kcsan_report_known_origin(const volatile void *ptr, size_t size, int access_type,
enum kcsan_value_change value_change, int watchpoint_idx, unsigned long ip, enum kcsan_value_change value_change,
u64 old, u64 new, u64 mask); int watchpoint_idx, u64 old, u64 new, u64 mask);
/* /*
* No other thread was observed to race with the access, but the data value * No other thread was observed to race with the access, but the data value
* before and after the stall differs. Reports a race of "unknown origin". * before and after the stall differs. Reports a race of "unknown origin".
*/ */
void kcsan_report_unknown_origin(const volatile void *ptr, size_t size, int access_type, void kcsan_report_unknown_origin(const volatile void *ptr, size_t size, int access_type,
u64 old, u64 new, u64 mask); unsigned long ip, u64 old, u64 new, u64 mask);
#endif /* _KERNEL_KCSAN_KCSAN_H */ #endif /* _KERNEL_KCSAN_KCSAN_H */
...@@ -31,6 +31,7 @@ struct access_info { ...@@ -31,6 +31,7 @@ struct access_info {
int access_type; int access_type;
int task_pid; int task_pid;
int cpu_id; int cpu_id;
unsigned long ip;
}; };
/* /*
...@@ -576,21 +577,22 @@ static bool prepare_report_consumer(unsigned long *flags, ...@@ -576,21 +577,22 @@ static bool prepare_report_consumer(unsigned long *flags,
} }
static struct access_info prepare_access_info(const volatile void *ptr, size_t size, static struct access_info prepare_access_info(const volatile void *ptr, size_t size,
int access_type) int access_type, unsigned long ip)
{ {
return (struct access_info) { return (struct access_info) {
.ptr = ptr, .ptr = ptr,
.size = size, .size = size,
.access_type = access_type, .access_type = access_type,
.task_pid = in_task() ? task_pid_nr(current) : -1, .task_pid = in_task() ? task_pid_nr(current) : -1,
.cpu_id = raw_smp_processor_id() .cpu_id = raw_smp_processor_id(),
.ip = ip,
}; };
} }
void kcsan_report_set_info(const volatile void *ptr, size_t size, int access_type, void kcsan_report_set_info(const volatile void *ptr, size_t size, int access_type,
int watchpoint_idx) unsigned long ip, int watchpoint_idx)
{ {
const struct access_info ai = prepare_access_info(ptr, size, access_type); const struct access_info ai = prepare_access_info(ptr, size, access_type, ip);
unsigned long flags; unsigned long flags;
kcsan_disable_current(); kcsan_disable_current();
...@@ -603,10 +605,10 @@ void kcsan_report_set_info(const volatile void *ptr, size_t size, int access_typ ...@@ -603,10 +605,10 @@ void kcsan_report_set_info(const volatile void *ptr, size_t size, int access_typ
} }
void kcsan_report_known_origin(const volatile void *ptr, size_t size, int access_type, void kcsan_report_known_origin(const volatile void *ptr, size_t size, int access_type,
enum kcsan_value_change value_change, int watchpoint_idx, unsigned long ip, enum kcsan_value_change value_change,
u64 old, u64 new, u64 mask) int watchpoint_idx, u64 old, u64 new, u64 mask)
{ {
const struct access_info ai = prepare_access_info(ptr, size, access_type); const struct access_info ai = prepare_access_info(ptr, size, access_type, ip);
struct other_info *other_info = &other_infos[watchpoint_idx]; struct other_info *other_info = &other_infos[watchpoint_idx];
unsigned long flags = 0; unsigned long flags = 0;
...@@ -637,9 +639,9 @@ void kcsan_report_known_origin(const volatile void *ptr, size_t size, int access ...@@ -637,9 +639,9 @@ void kcsan_report_known_origin(const volatile void *ptr, size_t size, int access
} }
void kcsan_report_unknown_origin(const volatile void *ptr, size_t size, int access_type, void kcsan_report_unknown_origin(const volatile void *ptr, size_t size, int access_type,
u64 old, u64 new, u64 mask) unsigned long ip, u64 old, u64 new, u64 mask)
{ {
const struct access_info ai = prepare_access_info(ptr, size, access_type); const struct access_info ai = prepare_access_info(ptr, size, access_type, ip);
unsigned long flags; unsigned long flags;
kcsan_disable_current(); kcsan_disable_current();
......
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