Skip to contentSkip to conversation

kcov: collect coverage from usb and vhost

PATCH Superseded Andrey Konovalov 4 participants 16 messages Oct 22, 2019 – Oct 24, 2019

Subsystems (10)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover kcov: collect coverage from usb and vhost

This patchset extends kcov to allow collecting coverage from the USB subsystem and vhost workers. See the first patch description for details about the kcov extension. The other two patches apply this kcov extension to USB and vhost.

These patches have been used to enable coverage-guided USB fuzzing with syzkaller for the last few years, see the details here:

https://github.com/google/syzkaller/blob/master/docs/linux/external_fuzzing_usb.md

This patchset has been pushed to the public Linux kernel Gerrit instance:

https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/1524

Changes from RFC v1:
- Remove unnecessary #ifdef's from drivers/vhost/vhost.c.
- Reset t->kcov when area allocation fails in kcov_remote_start().
- Use struct_size to calculate array size in kcov_ioctl().
- Add a limit on area_size in kcov_remote_arg.
- Added kcov_disable() helper.
- Changed encoding of kcov remote handle ids, see the documentation.
- Added a comment reference for kcov_sequence task_struct field.
- Change common_handle type to u32.
- Add checks for handle validity into kcov_ioctl_locked() and kcov_remote_start().
- Updated documentation to reflect the changes.

Andrey Konovalov (3):
kcov: remote coverage support
usb, kcov: collect coverage from hub_event
vhost, kcov: collect coverage from vhost_worker

 Documentation/dev-tools/kcov.rst | 120 ++++++++
 drivers/usb/core/hub.c           |   5 +
 drivers/vhost/vhost.c            |   6 +
 drivers/vhost/vhost.h            |   1 +
 include/linux/kcov.h             |   6 +
 include/linux/sched.h            |   6 +
 include/uapi/linux/kcov.h        |  20 ++
 kernel/kcov.c                    | 464 ++++++++++++++++++++++++++++---
 8 files changed, 593 insertions(+), 35 deletions(-)
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#1 lore raw

PATCH 1/3 kcov: remote coverage support

This patch adds background thread coverage collection ability to kcov.

With KCOV_ENABLE coverage is collected only for syscalls that are issued from the current process. With KCOV_REMOTE_ENABLE it's possible to collect coverage for arbitrary parts of the kernel code, provided that those parts are annotated with kcov_remote_start()/kcov_remote_stop().

This allows to collect coverage from two types of kernel background
threads: the global ones, that are spawned during kernel boot and are always running (e.g. USB hub_event()); and the local ones, that are spawned when a user interacts with some kernel interface (e.g. vhost workers).

To enable collecting coverage from a global background thread, a unique global handle must be assigned and passed to the corresponding kcov_remote_start() call. Then a userspace process can pass a list of such handles to the KCOV_REMOTE_ENABLE ioctl in the handles array field of the kcov_remote_arg struct. This will attach the used kcov device to the code sections, that are referenced by those handles.

Since there might be many local background threads spawned from different userspace processes, we can't use a single global handle per annotation. Instead, the userspace process passes a non-zero handle through the common_handle field of the kcov_remote_arg struct. This common handle gets saved to the kcov_handle field in the current task_struct and needs to be passed to the newly spawned threads via custom annotations. Those threads should in turn be annotated with kcov_remote_start()/kcov_remote_stop().

Internally kcov stores handles as u64 integers. The top byte of a handle is used to denote the id of a subsystem that this handle belongs to, and the lower 4 bytes are used to denote a handle id within that subsystem. A reserved value 0 is used as a subsystem id for common handles as they don't belong to a particular subsystem. The bytes 4-7 are currently reserved and must be zero. In the future the number of bytes used for the subsystem or handle ids might be increased.

When a particular userspace proccess collects coverage by via a common handle, kcov will collect coverage for each code section that is annotated to use the common handle obtained as kcov_handle from the current task_struct. However non common handles allow to collect coverage selectively from different subsystems.

---
 Documentation/dev-tools/kcov.rst | 120 ++++++++
 include/linux/kcov.h             |   6 +
 include/linux/sched.h            |   6 +
 include/uapi/linux/kcov.h        |  20 ++
 kernel/kcov.c                    | 464 ++++++++++++++++++++++++++++---
 5 files changed, 581 insertions(+), 35 deletions(-)
Documentation/dev-tools/kcov.rst +120 -0
index 42b612677799..089763aae15d 100644
@@ -34,6 +34,7 @@ Profiling data will only become accessible once debugfs has been mounted::
 
 Coverage collection
 -------------------
+
 The following program demonstrates coverage collection from within a test
 program using kcov:
 
@@ -128,6 +129,7 @@ only need to enable coverage (disable happens automatically on thread end).
 
 Comparison operands collection
 ------------------------------
+
 Comparison operands collection is similar to coverage collection:
 
 .. code-block:: c
@@ -202,3 +204,121 @@ Comparison operands collection is similar to coverage collection:
 
 Note that the kcov modes (coverage collection or comparison operands) are
 mutually exclusive.
+
+Remote coverage collection
+--------------------------
+
+With KCOV_ENABLE coverage is collected only for syscalls that are issued from
+the current process. With KCOV_REMOTE_ENABLE it's possible to collect coverage
+for arbitrary parts of the kernel code, provided that those parts are annotated
+with kcov_remote_start()/kcov_remote_stop().
+
+This allows to collect coverage from two types of kernel background threads:
+the global ones, that are spawned during kernel boot and are always running
+(e.g. USB hub_event()); and the local ones, that are spawned when a user
+interacts with some kernel interface (e.g. vhost workers).
+
+To enable collecting coverage from a global background thread, a unique global
+handle must be assigned and passed to the corresponding kcov_remote_start()
+call. Then a userspace process can pass a list of such handles to the
+KCOV_REMOTE_ENABLE ioctl in the handles array field of the kcov_remote_arg
+struct. This will attach the used kcov device to the code sections, that are
+referenced by those handles.
+
+Since there might be many local background threads spawned from different
+userspace processes, we can't use a single global handle per annotation.
+Instead, the userspace process passes a non-zero handle through the
+common_handle field of the kcov_remote_arg struct. This common handle gets
+saved to the kcov_handle field in the current task_struct and needs to be
+passed to the newly spawned threads via custom annotations. Those threads
+should in turn be annotated with kcov_remote_start()/kcov_remote_stop().
+
+Internally kcov stores handles as u64 integers. The top byte of a handle is
+used to denote the id of a subsystem that this handle belongs to, and the lower
+4 bytes are used to denote a handle id within that subsystem. A reserved value
+0 is used as a subsystem id for common handles as they don't belong to a
+particular subsystem. The bytes 4-7 are currently reserved and must be zero.
+In the future the number of bytes used for the subsystem or handle ids might
+be increased.
+
+When a particular userspace proccess collects coverage by via a common handle,
+kcov will collect coverage for each code section that is annotated to use the
+common handle obtained as kcov_handle from the current task_struct. However
+non common handles allow to collect coverage selectively from different
+subsystems.
+
+.. code-block:: c
+
+    struct kcov_remote_arg {
+	unsigned	trace_mode;
+	unsigned	area_size;
+	unsigned	num_handles;
+	uint32_t	common_handle;
+	uint64_t	handles[0];
+    };
+
+    #define KCOV_INIT_TRACE			_IOR('c', 1, unsigned long)
+    #define KCOV_DISABLE			_IO('c', 101)
+    #define KCOV_REMOTE_ENABLE		_IOW('c', 102, struct kcov_remote_arg)
+
+    #define COVER_SIZE	(64 << 10)
+
+    #define KCOV_TRACE_PC	0
+
+    #define KCOV_SUBSYSTEM_USB	0x01
+
+    static inline __u64 kcov_remote_handle_usb(__u32 bus)
+    {
+	return ((__u64)KCOV_SUBSYSTEM_USB << 56) | bus;
+    }
+
+    #define KCOV_COMMON_ID	0x42
+    #define KCOV_USB_BUS_NUM	1
+
+    int main(int argc, char **argv)
+    {
+	int fd;
+	unsigned long *cover, n, i;
+	struct kcov_remote_arg *arg;
+
+	fd = open("/sys/kernel/debug/kcov", O_RDWR);
+	if (fd == -1)
+		perror("open"), exit(1);
+	if (ioctl(fd, KCOV_INIT_TRACE, COVER_SIZE))
+		perror("ioctl"), exit(1);
+	cover = (unsigned long*)mmap(NULL, COVER_SIZE * sizeof(unsigned long),
+				     PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+	if ((void*)cover == MAP_FAILED)
+		perror("mmap"), exit(1);
+
+	/* Enable coverage collection via common handle and from USB bus #1. */
+	arg = calloc(1, sizeof(*arg) + sizeof(uint64_t));
+	if (!arg)
+		perror("calloc"), exit(1);
+	arg->trace_mode = KCOV_TRACE_PC;
+	arg->area_size = COVER_SIZE;
+	arg->num_handles = 1;
+	arg->common_handle = KCOV_COMMON_ID;
+	arg->handles[0] = kcov_remote_handle_usb(KCOV_USB_BUS_NUM);
+	if (ioctl(fd, KCOV_REMOTE_ENABLE, arg))
+		perror("ioctl"), free(arg), exit(1);
+	free(arg);
+
+	/*
+	 * Here the user needs to trigger execution of a kernel code section
+	 * that is either annotated with the common handle, or to trigger some
+	 * activity on USB bus #1.
+	 */
+	sleep(2);
+
+	n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED);
+	for (i = 0; i < n; i++)
+		printf("0x%lx\n", cover[i + 1]);
+	if (ioctl(fd, KCOV_DISABLE, 0))
+		perror("ioctl"), exit(1);
+	if (munmap(cover, COVER_SIZE * sizeof(unsigned long)))
+		perror("munmap"), exit(1);
+	if (close(fd))
+		perror("close"), exit(1);
+	return 0;
+    }
include/linux/kcov.h +6 -0
index b76a1807028d..061da4741966 100644
@@ -27,6 +27,10 @@ enum kcov_mode {
 void kcov_task_init(struct task_struct *t);
 void kcov_task_exit(struct task_struct *t);
 
+/* See Documentation/dev-tools/kcov.rst for usage details. */
+void kcov_remote_start(u64 handle);
+void kcov_remote_stop(void);
+
 #define kcov_prepare_switch(t)			\
 do {						\
 	(t)->kcov_mode |= KCOV_IN_CTXSW;	\
@@ -41,6 +45,8 @@ do {						\
 
 static inline void kcov_task_init(struct task_struct *t) {}
 static inline void kcov_task_exit(struct task_struct *t) {}
+static inline void kcov_remote_start(u64 handle) {}
+static inline void kcov_remote_stop(void) {}
 static inline void kcov_prepare_switch(struct task_struct *t) {}
 static inline void kcov_finish_switch(struct task_struct *t) {}
 
include/linux/sched.h +6 -0
index 67a1d86981a9..d828d924ce1e 100644
@@ -1214,6 +1214,12 @@ struct task_struct {
 
 	/* KCOV descriptor wired with this task or NULL: */
 	struct kcov			*kcov;
+
+	/* KCOV sequence number, see kernel/kcov.c for details: */
+	int				kcov_sequence;
+
+	/* KCOV common handle for remote coverage collection: */
+	u32				kcov_handle;
 #endif
 
 #ifdef CONFIG_MEMCG
include/uapi/linux/kcov.h +20 -0
index 9529867717a8..b5a1c5ba553f 100644
@@ -4,9 +4,21 @@
 
 #include <linux/types.h>
 
+/* See Documentation/dev-tools/kcov.rst for usage details. */
+struct kcov_remote_arg {
+	unsigned int	trace_mode;	/* KCOV_TRACE_PC or KCOV_TRACE_CMP */
+	unsigned int	area_size;	/* Length of coverage buffer in words */
+	unsigned int	num_handles;	/* Size of handles array */
+	__u32		common_handle;
+	__u64		handles[0];
+};
+
+#define KCOV_REMOTE_MAX_HANDLES		0x10000
+
 #define KCOV_INIT_TRACE			_IOR('c', 1, unsigned long)
 #define KCOV_ENABLE			_IO('c', 100)
 #define KCOV_DISABLE			_IO('c', 101)
+#define KCOV_REMOTE_ENABLE		_IOW('c', 102, struct kcov_remote_arg)
 
 enum {
 	/*
@@ -32,4 +44,12 @@ enum {
 #define KCOV_CMP_SIZE(n)        ((n) << 1)
 #define KCOV_CMP_MASK           KCOV_CMP_SIZE(3)
 
+#define KCOV_SUBSYSTEM_COMMON	0x00
+#define KCOV_SUBSYSTEM_USB	0x01
+
+static inline __u64 kcov_remote_handle_usb(unsigned int bus)
+{
+	return ((__u64)KCOV_SUBSYSTEM_USB << 56) | (__u64)bus;
+}
+
 #endif /* _LINUX_KCOV_IOCTLS_H */
kernel/kcov.c +429 -35

592 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#4 lore raw

PATCH 2/3 usb, kcov: collect coverage from hub_event

In reply to Andrey Konovalov

This patch adds kcov_remote_start()/kcov_remote_stop() annotations to the hub_event() function, which is responsible for processing events on USB buses, in particular events that happen during USB device enumeration. Since hub_event() is run in a global background kernel thread (see Documentation/dev-tools/kcov.rst for details), each USB bus gets a unique global handle id from the USB subsystem kcov handle id range. As the result kcov can now be used to collect coverage from events that happen on a particular USB bus.

---
 drivers/usb/core/hub.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/core/hub.c +5 -0
index 236313f41f4a..2634976dab3b 100644
@@ -29,6 +29,7 @@
 #include <linux/random.h>
 #include <linux/pm_qos.h>
 #include <linux/kobject.h>
+#include <linux/kcov.h>
 
 #include <linux/uaccess.h>
 #include <asm/byteorder.h>
@@ -5374,6 +5375,8 @@ static void hub_event(struct work_struct *work)
 	hub_dev = hub->intfdev;
 	intf = to_usb_interface(hub_dev);
 
+	kcov_remote_start(kcov_remote_handle_usb(hdev->bus->busnum));
+
 	dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
 			hdev->state, hdev->maxchild,
 			/* NOTE: expects max 15 ports... */
@@ -5480,6 +5483,8 @@ static void hub_event(struct work_struct *work)
 	/* Balance the stuff in kick_hub_wq() and allow autosuspend */
 	usb_autopm_put_interface(intf);
 	kref_put(&hub->kref, hub_release);
+
+	kcov_remote_stop();
 }
 
 static const struct usb_device_id hub_id_table[] = {
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#8 lore raw

PATCH 3/3 vhost, kcov: collect coverage from vhost_worker

In reply to Andrey Konovalov

This patch adds kcov_remote_start()/kcov_remote_stop() annotations to the vhost_worker() function, which is responsible for processing vhost works. Since vhost_worker() threads are spawned per vhost device instance the common kcov handle is used for kcov_remote_start()/stop() annotations (see Documentation/dev-tools/kcov.rst for details). As the result kcov can now be used to collect coverage from vhost worker threads.

---
 drivers/vhost/vhost.c | 6 ++++++
 drivers/vhost/vhost.h | 1 +
 2 files changed, 7 insertions(+)
drivers/vhost/vhost.c +6 -0
index 36ca2cf419bf..a5a557c4b67f 100644
@@ -30,6 +30,7 @@
 #include <linux/sched/signal.h>
 #include <linux/interval_tree_generic.h>
 #include <linux/nospec.h>
+#include <linux/kcov.h>
 
 #include "vhost.h"
 
@@ -357,7 +358,9 @@ static int vhost_worker(void *data)
 		llist_for_each_entry_safe(work, work_next, node, node) {
 			clear_bit(VHOST_WORK_QUEUED, &work->flags);
 			__set_current_state(TASK_RUNNING);
+			kcov_remote_start(dev->kcov_handle);
 			work->fn(work);
+			kcov_remote_stop();
 			if (need_resched())
 				schedule();
 		}
@@ -546,6 +549,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
 	/* No owner, become one */
 	dev->mm = get_task_mm(current);
+	dev->kcov_handle = current->kcov_handle;
 	worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid);
 	if (IS_ERR(worker)) {
 		err = PTR_ERR(worker);
@@ -571,6 +575,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 	if (dev->mm)
 		mmput(dev->mm);
 	dev->mm = NULL;
+	dev->kcov_handle = 0;
 err_mm:
 	return err;
 }
@@ -682,6 +687,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
 	if (dev->worker) {
 		kthread_stop(dev->worker);
 		dev->worker = NULL;
+		dev->kcov_handle = 0;
 	}
 	if (dev->mm)
 		mmput(dev->mm);
drivers/vhost/vhost.h +1 -0
index e9ed2722b633..a123fd70847e 100644
@@ -173,6 +173,7 @@ struct vhost_dev {
 	int iov_limit;
 	int weight;
 	int byte_weight;
+	u64 kcov_handle;
 };
 
 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#9 lore raw

Re: [PATCH 3/3] vhost, kcov: collect coverage from vhost_worker

Quoted 37 lines · Andrey Konovalov

This patch adds kcov_remote_start()/kcov_remote_stop() annotations to the vhost_worker() function, which is responsible for processing vhost works. Since vhost_worker() threads are spawned per vhost device instance the common kcov handle is used for kcov_remote_start()/stop() annotations (see Documentation/dev-tools/kcov.rst for details). As the result kcov can now be used to collect coverage from vhost worker threads.

---
 drivers/vhost/vhost.c | 6 ++++++
 drivers/vhost/vhost.h | 1 +
 2 files changed, 7 insertions(+)
drivers/vhost/vhost.c +3 -0
index 36ca2cf419bf..a5a557c4b67f 100644
@@ -30,6 +30,7 @@
 #include <linux/sched/signal.h>
 #include <linux/interval_tree_generic.h>
 #include <linux/nospec.h>
+#include <linux/kcov.h>
 
 #include "vhost.h"
 
@@ -357,7 +358,9 @@ static int vhost_worker(void *data)
                llist_for_each_entry_safe(work, work_next, node, node) {
                        clear_bit(VHOST_WORK_QUEUED, &work->flags);
                        __set_current_state(TASK_RUNNING);
+                       kcov_remote_start(dev->kcov_handle);
                        work->fn(work);
+                       kcov_remote_stop();
                        if (need_resched())
                                schedule();
                }

drivers/vhost/vhost.c long vhost_dev_set_owner(struct vhost_dev *dev) · line 552

Quoted 4 lines
drivers/vhost/vhost.c +1 -0
@@ -546,6 +549,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
        /* No owner, become one */
        dev->mm = get_task_mm(current);
+       dev->kcov_handle = current->kcov_handle;

kcov_handle is not present in task_struct if !CONFIG_KCOV

Also this does not use KCOV_SUBSYSTEM_COMMON.
We discussed something along the following lines:

u64 kcov_remote_handle(u64 subsys, u64 id)
{
WARN_ON(subsys or id has wrong bits set).
return ...;
}

kcov_remote_handle(KCOV_SUBSYSTEM_USB, bus); kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, current->kcov_handle);

Quoted 34 lines
drivers/vhost/vhost.c +2 -0
        worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid);
        if (IS_ERR(worker)) {
                err = PTR_ERR(worker);
@@ -571,6 +575,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
        if (dev->mm)
                mmput(dev->mm);
        dev->mm = NULL;
+       dev->kcov_handle = 0;
 err_mm:
        return err;
 }
@@ -682,6 +687,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
        if (dev->worker) {
                kthread_stop(dev->worker);
                dev->worker = NULL;
+               dev->kcov_handle = 0;
        }
        if (dev->mm)
                mmput(dev->mm);
drivers/vhost/vhost.h +1 -1
index e9ed2722b633..a123fd70847e 100644
@@ -173,6 +173,7 @@ struct vhost_dev {
        int iov_limit;
        int weight;
        int byte_weight;
+       u64 kcov_handle;
 };
 
 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
--

2.23.0.866.gb869b98d4c-goog

reviewer
#10 lore raw

Re: [PATCH 3/3] vhost, kcov: collect coverage from vhost_worker

In reply to Andrey Konovalov
Quoted 37 lines · Andrey Konovalov

This patch adds kcov_remote_start()/kcov_remote_stop() annotations to the vhost_worker() function, which is responsible for processing vhost works. Since vhost_worker() threads are spawned per vhost device instance the common kcov handle is used for kcov_remote_start()/stop() annotations (see Documentation/dev-tools/kcov.rst for details). As the result kcov can now be used to collect coverage from vhost worker threads.

---
 drivers/vhost/vhost.c | 6 ++++++
 drivers/vhost/vhost.h | 1 +
 2 files changed, 7 insertions(+)
drivers/vhost/vhost.c +3 -0
index 36ca2cf419bf..a5a557c4b67f 100644
@@ -30,6 +30,7 @@
 #include <linux/sched/signal.h>
 #include <linux/interval_tree_generic.h>
 #include <linux/nospec.h>
+#include <linux/kcov.h>
 
 #include "vhost.h"
 
@@ -357,7 +358,9 @@ static int vhost_worker(void *data)
                llist_for_each_entry_safe(work, work_next, node, node) {
                        clear_bit(VHOST_WORK_QUEUED, &work->flags);
                        __set_current_state(TASK_RUNNING);
+                       kcov_remote_start(dev->kcov_handle);
                        work->fn(work);
+                       kcov_remote_stop();
                        if (need_resched())
                                schedule();
                }

drivers/vhost/vhost.c long vhost_dev_set_owner(struct vhost_dev *dev) · line 552

Quoted 4 lines
drivers/vhost/vhost.c +1 -0
@@ -546,6 +549,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
        /* No owner, become one */
        dev->mm = get_task_mm(current);
+       dev->kcov_handle = current->kcov_handle;

kcov_handle is not present in task_struct if !CONFIG_KCOV

Also this does not use KCOV_SUBSYSTEM_COMMON.
We discussed something along the following lines:

u64 kcov_remote_handle(u64 subsys, u64 id)
{
WARN_ON(subsys or id has wrong bits set).
return ...;
}

kcov_remote_handle(KCOV_SUBSYSTEM_USB, bus); kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, current->kcov_handle);

Quoted 34 lines
drivers/vhost/vhost.c +2 -0
        worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid);
        if (IS_ERR(worker)) {
                err = PTR_ERR(worker);
@@ -571,6 +575,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
        if (dev->mm)
                mmput(dev->mm);
        dev->mm = NULL;
+       dev->kcov_handle = 0;
 err_mm:
        return err;
 }
@@ -682,6 +687,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
        if (dev->worker) {
                kthread_stop(dev->worker);
                dev->worker = NULL;
+               dev->kcov_handle = 0;
        }
        if (dev->mm)
                mmput(dev->mm);
drivers/vhost/vhost.h +1 -1
index e9ed2722b633..a123fd70847e 100644
@@ -173,6 +173,7 @@ struct vhost_dev {
        int iov_limit;
        int weight;
        int byte_weight;
+       u64 kcov_handle;
 };
 
 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
--

2.23.0.866.gb869b98d4c-goog

reviewer
#15 lore raw
In reply to Andrey Konovalov
Quoted 6 lines · Andrey Konovalov

This patchset extends kcov to allow collecting coverage from the USB subsystem and vhost workers. See the first patch description for details about the kcov extension. The other two patches apply this kcov extension to USB and vhost.

Quoted 8 lines

These patches have been used to enable coverage-guided USB fuzzing with syzkaller for the last few years, see the details here:

https://github.com/google/syzkaller/blob/master/docs/linux/external_fuzzing_usb.md

This patchset has been pushed to the public Linux kernel Gerrit instance:

https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/1524

Oh, so much easier to review with side-by-side diffs, context and smart in-line colouring!

Quoted 31 lines

Changes from RFC v1:
- Remove unnecessary #ifdef's from drivers/vhost/vhost.c.
- Reset t->kcov when area allocation fails in kcov_remote_start().
- Use struct_size to calculate array size in kcov_ioctl().
- Add a limit on area_size in kcov_remote_arg.
- Added kcov_disable() helper.
- Changed encoding of kcov remote handle ids, see the documentation.
- Added a comment reference for kcov_sequence task_struct field.
- Change common_handle type to u32.
- Add checks for handle validity into kcov_ioctl_locked() and kcov_remote_start().
- Updated documentation to reflect the changes.

Andrey Konovalov (3):
kcov: remote coverage support
usb, kcov: collect coverage from hub_event
vhost, kcov: collect coverage from vhost_worker

 Documentation/dev-tools/kcov.rst | 120 ++++++++
 drivers/usb/core/hub.c           |   5 +
 drivers/vhost/vhost.c            |   6 +
 drivers/vhost/vhost.h            |   1 +
 include/linux/kcov.h             |   6 +
 include/linux/sched.h            |   6 +
 include/uapi/linux/kcov.h        |  20 ++
 kernel/kcov.c                    | 464 ++++++++++++++++++++++++++++---
 8 files changed, 593 insertions(+), 35 deletions(-)

--
2.23.0.866.gb869b98d4c-goog

#11 lore raw

Re: [PATCH 3/3] vhost, kcov: collect coverage from vhost_worker

In reply to Dmitry Vyukov
Quoted 46 lines · Dmitry Vyukov
Quoted 37 lines · Andrey Konovalov

This patch adds kcov_remote_start()/kcov_remote_stop() annotations to the vhost_worker() function, which is responsible for processing vhost works. Since vhost_worker() threads are spawned per vhost device instance the common kcov handle is used for kcov_remote_start()/stop() annotations (see Documentation/dev-tools/kcov.rst for details). As the result kcov can now be used to collect coverage from vhost worker threads.

---
 drivers/vhost/vhost.c | 6 ++++++
 drivers/vhost/vhost.h | 1 +
 2 files changed, 7 insertions(+)
drivers/vhost/vhost.c +3 -0
index 36ca2cf419bf..a5a557c4b67f 100644
@@ -30,6 +30,7 @@
 #include <linux/sched/signal.h>
 #include <linux/interval_tree_generic.h>
 #include <linux/nospec.h>
+#include <linux/kcov.h>
 
 #include "vhost.h"
 
@@ -357,7 +358,9 @@ static int vhost_worker(void *data)
                llist_for_each_entry_safe(work, work_next, node, node) {
                        clear_bit(VHOST_WORK_QUEUED, &work->flags);
                        __set_current_state(TASK_RUNNING);
+                       kcov_remote_start(dev->kcov_handle);
                        work->fn(work);
+                       kcov_remote_stop();
                        if (need_resched())
                                schedule();
                }

drivers/vhost/vhost.c long vhost_dev_set_owner(struct vhost_dev *dev) · line 552

Quoted 4 lines
drivers/vhost/vhost.c +1 -0
@@ -546,6 +549,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
        /* No owner, become one */
        dev->mm = get_task_mm(current);
+       dev->kcov_handle = current->kcov_handle;

kcov_handle is not present in task_struct if !CONFIG_KCOV

Quoted 6 lines

Also this does not use KCOV_SUBSYSTEM_COMMON.
We discussed something along the following lines:

u64 kcov_remote_handle(u64 subsys, u64 id)
{
WARN_ON(subsys or id has wrong bits set).

Hm, we can't have warnings in kcov_remote_handle() that is exposed in uapi headers. What we can do is return 0 (invalid handle) if subsys/id have incorrect bits set. And then we can either have another kcov_remote_handle() internally (with a different name though) that has a warning, or have warning in kcov_remote_start(). WDYT?

Quoted 41 lines

return ...;
}

kcov_remote_handle(KCOV_SUBSYSTEM_USB, bus); kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, current->kcov_handle);

Quoted 34 lines
drivers/vhost/vhost.c +2 -0
        worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid);
        if (IS_ERR(worker)) {
                err = PTR_ERR(worker);
@@ -571,6 +575,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
        if (dev->mm)
                mmput(dev->mm);
        dev->mm = NULL;
+       dev->kcov_handle = 0;
 err_mm:
        return err;
 }
@@ -682,6 +687,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
        if (dev->worker) {
                kthread_stop(dev->worker);
                dev->worker = NULL;
+               dev->kcov_handle = 0;
        }
        if (dev->mm)
                mmput(dev->mm);
drivers/vhost/vhost.h +1 -1
index e9ed2722b633..a123fd70847e 100644
@@ -173,6 +173,7 @@ struct vhost_dev {
        int iov_limit;
        int weight;
        int byte_weight;
+       u64 kcov_handle;
 };
 
 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
--

2.23.0.866.gb869b98d4c-goog

#12 lore raw

Re: [PATCH 3/3] vhost, kcov: collect coverage from vhost_worker

Quoted 55 lines · Andrey Konovalov
Quoted 46 lines · Dmitry Vyukov
Quoted 37 lines · Andrey Konovalov

This patch adds kcov_remote_start()/kcov_remote_stop() annotations to the vhost_worker() function, which is responsible for processing vhost works. Since vhost_worker() threads are spawned per vhost device instance the common kcov handle is used for kcov_remote_start()/stop() annotations (see Documentation/dev-tools/kcov.rst for details). As the result kcov can now be used to collect coverage from vhost worker threads.

---
 drivers/vhost/vhost.c | 6 ++++++
 drivers/vhost/vhost.h | 1 +
 2 files changed, 7 insertions(+)
drivers/vhost/vhost.c +3 -0
index 36ca2cf419bf..a5a557c4b67f 100644
@@ -30,6 +30,7 @@
 #include <linux/sched/signal.h>
 #include <linux/interval_tree_generic.h>
 #include <linux/nospec.h>
+#include <linux/kcov.h>
 
 #include "vhost.h"
 
@@ -357,7 +358,9 @@ static int vhost_worker(void *data)
                llist_for_each_entry_safe(work, work_next, node, node) {
                        clear_bit(VHOST_WORK_QUEUED, &work->flags);
                        __set_current_state(TASK_RUNNING);
+                       kcov_remote_start(dev->kcov_handle);
                        work->fn(work);
+                       kcov_remote_stop();
                        if (need_resched())
                                schedule();
                }

drivers/vhost/vhost.c long vhost_dev_set_owner(struct vhost_dev *dev) · line 552

Quoted 4 lines
drivers/vhost/vhost.c +1 -0
@@ -546,6 +549,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
        /* No owner, become one */
        dev->mm = get_task_mm(current);
+       dev->kcov_handle = current->kcov_handle;

kcov_handle is not present in task_struct if !CONFIG_KCOV

Quoted 6 lines

Also this does not use KCOV_SUBSYSTEM_COMMON.
We discussed something along the following lines:

u64 kcov_remote_handle(u64 subsys, u64 id)
{
WARN_ON(subsys or id has wrong bits set).

Quoted 5 lines

Hm, we can't have warnings in kcov_remote_handle() that is exposed in uapi headers. What we can do is return 0 (invalid handle) if subsys/id have incorrect bits set. And then we can either have another kcov_remote_handle() internally (with a different name though) that has a warning, or have warning in kcov_remote_start(). WDYT?

I would probably add the warning to kcov_remote_start(). This avoids the need for another function and will catch a wrong ID if caller generated it by some other means.
And then ioctls should also detect bad handles passed in and return EINVAL. Then we will cover errors for both kernel and user programs.

Quoted 42 lines
Quoted 42 lines

return ...;
}

kcov_remote_handle(KCOV_SUBSYSTEM_USB, bus); kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, current->kcov_handle);

Quoted 34 lines
drivers/vhost/vhost.c +2 -0
        worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid);
        if (IS_ERR(worker)) {
                err = PTR_ERR(worker);
@@ -571,6 +575,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
        if (dev->mm)
                mmput(dev->mm);
        dev->mm = NULL;
+       dev->kcov_handle = 0;
 err_mm:
        return err;
 }
@@ -682,6 +687,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
        if (dev->worker) {
                kthread_stop(dev->worker);
                dev->worker = NULL;
+               dev->kcov_handle = 0;
        }
        if (dev->mm)
                mmput(dev->mm);
drivers/vhost/vhost.h +1 -1
index e9ed2722b633..a123fd70847e 100644
@@ -173,6 +173,7 @@ struct vhost_dev {
        int iov_limit;
        int weight;
        int byte_weight;
+       u64 kcov_handle;
 };
 
 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
--

2.23.0.866.gb869b98d4c-goog

reviewer
#13 lore raw

Re: [PATCH 3/3] vhost, kcov: collect coverage from vhost_worker

In reply to Andrey Konovalov
Quoted 55 lines · Andrey Konovalov
Quoted 46 lines · Dmitry Vyukov
Quoted 37 lines · Andrey Konovalov

This patch adds kcov_remote_start()/kcov_remote_stop() annotations to the vhost_worker() function, which is responsible for processing vhost works. Since vhost_worker() threads are spawned per vhost device instance the common kcov handle is used for kcov_remote_start()/stop() annotations (see Documentation/dev-tools/kcov.rst for details). As the result kcov can now be used to collect coverage from vhost worker threads.

---
 drivers/vhost/vhost.c | 6 ++++++
 drivers/vhost/vhost.h | 1 +
 2 files changed, 7 insertions(+)
drivers/vhost/vhost.c +3 -0
index 36ca2cf419bf..a5a557c4b67f 100644
@@ -30,6 +30,7 @@
 #include <linux/sched/signal.h>
 #include <linux/interval_tree_generic.h>
 #include <linux/nospec.h>
+#include <linux/kcov.h>
 
 #include "vhost.h"
 
@@ -357,7 +358,9 @@ static int vhost_worker(void *data)
                llist_for_each_entry_safe(work, work_next, node, node) {
                        clear_bit(VHOST_WORK_QUEUED, &work->flags);
                        __set_current_state(TASK_RUNNING);
+                       kcov_remote_start(dev->kcov_handle);
                        work->fn(work);
+                       kcov_remote_stop();
                        if (need_resched())
                                schedule();
                }

drivers/vhost/vhost.c long vhost_dev_set_owner(struct vhost_dev *dev) · line 552

Quoted 4 lines
drivers/vhost/vhost.c +1 -0
@@ -546,6 +549,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
        /* No owner, become one */
        dev->mm = get_task_mm(current);
+       dev->kcov_handle = current->kcov_handle;

kcov_handle is not present in task_struct if !CONFIG_KCOV

Quoted 6 lines

Also this does not use KCOV_SUBSYSTEM_COMMON.
We discussed something along the following lines:

u64 kcov_remote_handle(u64 subsys, u64 id)
{
WARN_ON(subsys or id has wrong bits set).

Quoted 5 lines

Hm, we can't have warnings in kcov_remote_handle() that is exposed in uapi headers. What we can do is return 0 (invalid handle) if subsys/id have incorrect bits set. And then we can either have another kcov_remote_handle() internally (with a different name though) that has a warning, or have warning in kcov_remote_start(). WDYT?

I would probably add the warning to kcov_remote_start(). This avoids the need for another function and will catch a wrong ID if caller generated it by some other means.
And then ioctls should also detect bad handles passed in and return EINVAL. Then we will cover errors for both kernel and user programs.

Quoted 42 lines
Quoted 42 lines

return ...;
}

kcov_remote_handle(KCOV_SUBSYSTEM_USB, bus); kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, current->kcov_handle);

Quoted 34 lines
drivers/vhost/vhost.c +2 -0
        worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid);
        if (IS_ERR(worker)) {
                err = PTR_ERR(worker);
@@ -571,6 +575,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
        if (dev->mm)
                mmput(dev->mm);
        dev->mm = NULL;
+       dev->kcov_handle = 0;
 err_mm:
        return err;
 }
@@ -682,6 +687,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
        if (dev->worker) {
                kthread_stop(dev->worker);
                dev->worker = NULL;
+               dev->kcov_handle = 0;
        }
        if (dev->mm)
                mmput(dev->mm);
drivers/vhost/vhost.h +1 -1
index e9ed2722b633..a123fd70847e 100644
@@ -173,6 +173,7 @@ struct vhost_dev {
        int iov_limit;
        int weight;
        int byte_weight;
+       u64 kcov_handle;
 };
 
 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
--

2.23.0.866.gb869b98d4c-goog

#14 lore raw

Re: [PATCH 3/3] vhost, kcov: collect coverage from vhost_worker

Quoted 63 lines · Dmitry Vyukov
Quoted 55 lines · Andrey Konovalov
Quoted 46 lines · Dmitry Vyukov
Quoted 37 lines · Andrey Konovalov

This patch adds kcov_remote_start()/kcov_remote_stop() annotations to the vhost_worker() function, which is responsible for processing vhost works. Since vhost_worker() threads are spawned per vhost device instance the common kcov handle is used for kcov_remote_start()/stop() annotations (see Documentation/dev-tools/kcov.rst for details). As the result kcov can now be used to collect coverage from vhost worker threads.

---
 drivers/vhost/vhost.c | 6 ++++++
 drivers/vhost/vhost.h | 1 +
 2 files changed, 7 insertions(+)
drivers/vhost/vhost.c +3 -0
index 36ca2cf419bf..a5a557c4b67f 100644
@@ -30,6 +30,7 @@
 #include <linux/sched/signal.h>
 #include <linux/interval_tree_generic.h>
 #include <linux/nospec.h>
+#include <linux/kcov.h>
 
 #include "vhost.h"
 
@@ -357,7 +358,9 @@ static int vhost_worker(void *data)
                llist_for_each_entry_safe(work, work_next, node, node) {
                        clear_bit(VHOST_WORK_QUEUED, &work->flags);
                        __set_current_state(TASK_RUNNING);
+                       kcov_remote_start(dev->kcov_handle);
                        work->fn(work);
+                       kcov_remote_stop();
                        if (need_resched())
                                schedule();
                }

drivers/vhost/vhost.c long vhost_dev_set_owner(struct vhost_dev *dev) · line 552

Quoted 4 lines
drivers/vhost/vhost.c +1 -0
@@ -546,6 +549,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
        /* No owner, become one */
        dev->mm = get_task_mm(current);
+       dev->kcov_handle = current->kcov_handle;

kcov_handle is not present in task_struct if !CONFIG_KCOV

Quoted 6 lines

Also this does not use KCOV_SUBSYSTEM_COMMON.
We discussed something along the following lines:

u64 kcov_remote_handle(u64 subsys, u64 id)
{
WARN_ON(subsys or id has wrong bits set).

Quoted 5 lines

Hm, we can't have warnings in kcov_remote_handle() that is exposed in uapi headers. What we can do is return 0 (invalid handle) if subsys/id have incorrect bits set. And then we can either have another kcov_remote_handle() internally (with a different name though) that has a warning, or have warning in kcov_remote_start(). WDYT?

Quoted 5 lines

I would probably add the warning to kcov_remote_start(). This avoids the need for another function and will catch a wrong ID if caller generated it by some other means.
And then ioctls should also detect bad handles passed in and return EINVAL. Then we will cover errors for both kernel and user programs.

OK, will do in v2.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

return ...;
}

kcov_remote_handle(KCOV_SUBSYSTEM_USB, bus); kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, current->kcov_handle);

I'll add internal kcov_remote_handle_common() and kcov_remote_handle_usb() helpers to simplify kcov hooks in usb/vhost code though.

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
drivers/vhost/vhost.c +2 -0
        worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid);
        if (IS_ERR(worker)) {
                err = PTR_ERR(worker);
@@ -571,6 +575,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
        if (dev->mm)
                mmput(dev->mm);
        dev->mm = NULL;
+       dev->kcov_handle = 0;
 err_mm:
        return err;
 }
@@ -682,6 +687,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
        if (dev->worker) {
                kthread_stop(dev->worker);
                dev->worker = NULL;
+               dev->kcov_handle = 0;
        }
        if (dev->mm)
                mmput(dev->mm);
drivers/vhost/vhost.h +1 -1
index e9ed2722b633..a123fd70847e 100644
@@ -173,6 +173,7 @@ struct vhost_dev {
        int iov_limit;
        int weight;
        int byte_weight;
+       u64 kcov_handle;
 };
 
 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
--

2.23.0.866.gb869b98d4c-goog

#2 lore raw

Re: [PATCH 1/3] kcov: remote coverage support

In reply to Andrey Konovalov
Thank you for the patch! Yet something to improve:

Hi Andrey,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc4 next-20191023]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andrey-Konovalov/kcov-collect-coverage-from-usb-and-vhost/20191023-185245
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3b7c59a1950c75f2c0152e5a9cd77675b09233d6
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=arm

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

kernel/kcov.o: In function `kcov_remote_stop':

>> kcov.c:(.text+0x1094): undefined reference to `__aeabi_uldivmod'

kcov.c:(.text+0x1144): undefined reference to `__aeabi_uldivmod'

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#5 lore raw

Re: [PATCH 2/3] usb, kcov: collect coverage from hub_event

In reply to Andrey Konovalov
Thank you for the patch! Yet something to improve:

Hi Andrey,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc4 next-20191023]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andrey-Konovalov/kcov-collect-coverage-from-usb-and-vhost/20191023-185245
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3b7c59a1950c75f2c0152e5a9cd77675b09233d6
config: s390-allmodconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=s390

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

>> ERROR: "kcov_remote_stop" [drivers/usb/core/usbcore.ko] undefined!
>> ERROR: "kcov_remote_start" [drivers/usb/core/usbcore.ko] undefined!

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#7 lore raw

Re: [PATCH 2/3] usb, kcov: collect coverage from hub_event

In reply to Andrey Konovalov
Thank you for the patch! Yet something to improve:

Hi Andrey,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc4 next-20191023]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andrey-Konovalov/kcov-collect-coverage-from-usb-and-vhost/20191023-185245
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3b7c59a1950c75f2c0152e5a9cd77675b09233d6
config: s390-allmodconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=s390

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

>> ERROR: "kcov_remote_stop" [drivers/usb/core/usbcore.ko] undefined!
>> ERROR: "kcov_remote_start" [drivers/usb/core/usbcore.ko] undefined!

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw

Re: [PATCH 1/3] kcov: remote coverage support

In reply to kbuild test robot
Quoted 21 lines · kbuild test robot

Hi Andrey,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc4 next-20191023]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andrey-Konovalov/kcov-collect-coverage-from-usb-and-vhost/20191023-185245
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3b7c59a1950c75f2c0152e5a9cd77675b09233d6
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=arm

Quoted 8 lines

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

kernel/kcov.o: In function `kcov_remote_stop':

Quoted 1 line
Quoted 1 line

kcov.c:(.text+0x1094): undefined reference to `__aeabi_uldivmod'

kcov.c:(.text+0x1144): undefined reference to `__aeabi_uldivmod'

OK, looks like arm32 can't divide 64 bit integers. Will fix in v3.

Quoted 4 lines

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#6 lore raw

Re: [PATCH 2/3] usb, kcov: collect coverage from hub_event

In reply to kbuild test robot
Quoted 21 lines · kbuild test robot

Hi Andrey,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc4 next-20191023]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andrey-Konovalov/kcov-collect-coverage-from-usb-and-vhost/20191023-185245
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3b7c59a1950c75f2c0152e5a9cd77675b09233d6
config: s390-allmodconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=s390

Quoted 7 lines

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

Quoted 2 lines
Quoted 2 lines

ERROR: "kcov_remote_stop" [drivers/usb/core/usbcore.ko] undefined!
ERROR: "kcov_remote_start" [drivers/usb/core/usbcore.ko] undefined!

Indeed, we need EXPORT_SYMBOL() for kcov_common_handle(), kcov_remote_start() and kcov_remote_stop(). Will fix in v3.

Quoted 4 lines

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation