Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7855a48f authored by Blagovest Kolenichev's avatar Blagovest Kolenichev
Browse files

Merge android-5.4.12 (4bbb9606) into msm-5.4



* refs/heads/tmp-4bbb9606:
  Revert "BACKPORT: FROMLIST: Update Inline Encryption from v5 to v6 of patch series"
  GKI: enable CONFIG_NETFILTER_XT_MATCH_QUOTA2_LOG=y
  Linux 5.4.12
  drm/i915/gen9: Clear residual context state on context switch
  netfilter: ipset: avoid null deref when IPSET_ATTR_LINENO is present
  netfilter: conntrack: dccp, sctp: handle null timeout argument
  netfilter: arp_tables: init netns pointer in xt_tgchk_param struct
  phy: cpcap-usb: Fix flakey host idling and enumerating of devices
  phy: cpcap-usb: Fix error path when no host driver is loaded
  USB: Fix: Don't skip endpoint descriptors with maxpacket=0
  HID: hiddev: fix mess in hiddev_open()
  ath10k: fix memory leak
  rtl8xxxu: prevent leaking urb
  scsi: bfa: release allocated memory in case of error
  rpmsg: char: release allocated memory
  mwifiex: pcie: Fix memory leak in mwifiex_pcie_alloc_cmdrsp_buf
  mwifiex: fix possible heap overflow in mwifiex_process_country_ie()
  staging: vt6656: remove bool from vnt_radio_power_on ret
  um: Implement copy_thread_tls
  clone3: ensure copy_thread_tls is implemented
  xtensa: Implement copy_thread_tls
  riscv: Implement copy_thread_tls
  parisc: Implement copy_thread_tls
  arm: Implement copy_thread_tls
  arm64: Implement copy_thread_tls
  arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers
  tty: always relink the port
  tty: link tty and port before configuring it as console
  iommu/vt-d: Fix adding non-PCI devices to Intel IOMMU
  serdev: Don't claim unsupported ACPI serial devices
  staging: rtl8188eu: Add device code for TP-Link TL-WN727N v5.21
  staging: vt6656: limit reg output to block size
  staging: vt6656: correct return of vnt_init_registers.
  staging: comedi: adv_pci1710: fix AI channels 16-31 for PCI-1713
  usb: musb: dma: Correct parameter passed to IRQ handler
  usb: musb: Disable pullup at init
  usb: musb: fix idling for suspend after disconnect interrupt
  USB: serial: option: add ZLP support for 0x1bc7/0x9010
  USB-PD tcpm: bad warning+size, PPS adapters
  usb: ohci-da8xx: ensure error return on variable error is set
  usb: cdns3: should not use the same dev_id for shared interrupt handler
  staging: vt6656: Fix non zero logical return of, usb_control_msg
  staging: vt6656: set usb_set_intfdata on driver fail.
  pstore/ram: Regularize prz label allocation lifetime
  gpiolib: acpi: Add honor_wakeup module-option + quirk mechanism
  gpiolib: acpi: Turn dmi_system_id table into a generic quirk table
  can: can_dropped_invalid_skb(): ensure an initialized headroom in outgoing CAN sk_buffs
  can: mscan: mscan_rx_poll(): fix rx path lockup when returning from polling to irq mode
  can: tcan4x5x: tcan4x5x_can_probe(): get the device out of standby before register access
  can: gs_usb: gs_usb_probe(): use descriptors of current altsetting
  can: kvaser_usb: fix interface sanity check
  IB/hfi1: Adjust flow PSN with the correct resync_psn
  drm/i915/gt: Mark up virtual engine uabi_instance
  drm/i915: Add Wa_1407352427:icl,ehl
  drm/dp_mst: correct the shifting in DP_REMOTE_I2C_READ
  drm/fb-helper: Round up bits_per_pixel if possible
  drm/sun4i: tcon: Set RGB DCLK min. divider based on hardware model
  Revert "drm/amdgpu: Set no-retry as default."
  drm/i915: Add Wa_1408615072 and Wa_1407596294 to icl,ehl
  Input: input_event - fix struct padding on sparc64
  Input: add safety guards to input_set_keycode()
  HID: hid-input: clear unmapped usages
  HID: hidraw: Fix returning EPOLLOUT from hidraw_poll
  HID: uhid: Fix returning EPOLLOUT from uhid_char_poll
  HID: Fix slab-out-of-bounds read in hid_field_extract
  tracing: Change offset type to s32 in preempt/irq tracepoints
  tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined
  kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail
  rtc: sun6i: Add support for RTC clocks on R40
  tpm: Handle negative priv->response_len in tpm_common_read()
  tpm: Revert "tpm_tis_core: Turn on the TPM before probing IRQ's"
  tpm: Revert "tpm_tis_core: Set TPM_CHIP_FLAG_IRQ before probing for interrupts"
  tpm: Revert "tpm_tis: reserve chip for duration of tpm_tis_core_init"
  ALSA: hda/realtek - Add quirk for the bass speaker on Lenovo Yoga X1 7th gen
  ALSA: hda/realtek - Set EAPD control to default for ALC222
  ALSA: hda/realtek - Add new codec supported for ALCS1200A
  ALSA: usb-audio: Apply the sample rate quirk for Bose Companion 5
  usb: chipidea: host: Disable port power only if previously enabled
  powercap: intel_rapl: add NULL pointer check to rapl_mmio_cpu_online()
  i2c: fix bus recovery stop mode timing
  chardev: Avoid potential use-after-free in 'chrdev_open()'
  UPSTREAM: vhost, kcov: collect coverage from vhost_worker
  UPSTREAM: usb, kcov: collect coverage from hub_event
  ANDROID: update kernel ABI for kcov changes
  UPSTREAM: kcov: remote coverage support
  ANDROID: gki_defconfig: Enable blk-crypto fallback
  BACKPORT: FROMLIST: Update Inline Encryption from v5 to v6 of patch series
  ANDROID: tty: serdev: Fix broken serial console input
  ANDROID: reset: hisi-reboot: adb reboot bootloader

Change-Id: I6e1ce85864cd7c26ad17d2d6bc12232433d50bde
Signed-off-by: default avatarBlagovest Kolenichev <bkolenichev@codeaurora.org>
parents 6ec8cd9d 49107cf0
Loading
Loading
Loading
Loading
+129 −0
Original line number Diff line number Diff line
@@ -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,130 @@ 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 in a limited
number of instances (e.g. one USB hub_event() worker thread is spawned per
USB HCD); 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 the id of a thread instance 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;
	uint64_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_COMMON	(0x00ull << 56)
    #define KCOV_SUBSYSTEM_USB	(0x01ull << 56)

    #define KCOV_SUBSYSTEM_MASK	(0xffull << 56)
    #define KCOV_INSTANCE_MASK	(0xffffffffull)

    static inline __u64 kcov_remote_handle(__u64 subsys, __u64 inst)
    {
	if (subsys & ~KCOV_SUBSYSTEM_MASK || inst & ~KCOV_INSTANCE_MASK)
		return 0;
	return subsys | inst;
    }

    #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_remote_handle(KCOV_SUBSYSTEM_COMMON,
							KCOV_COMMON_ID);
	arg->handles[0] = kcov_remote_handle(KCOV_SUBSYSTEM_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;
    }
+1 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
VERSION = 5
PATCHLEVEL = 4
SUBLEVEL = 11
SUBLEVEL = 12
EXTRAVERSION =
NAME = Kleptomaniac Octopus

+9128 −9367

File changed.

Preview size limit exceeded, changes collapsed.

+15976 −16037

File changed and moved.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ config ARM
	select HAVE_ARM_SMCCC if CPU_V7
	select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32
	select HAVE_CONTEXT_TRACKING
	select HAVE_COPY_THREAD_TLS
	select HAVE_C_RECORDMCOUNT
	select HAVE_DEBUG_KMEMLEAK
	select HAVE_DMA_CONTIGUOUS if MMU
Loading