Commit f9e2bb42 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'perf-tools-fixes-for-v5.12-2020-03-28' of...

Merge tag 'perf-tools-fixes-for-v5.12-2020-03-28' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull perf tooling fixes from Arnaldo Carvalho de Melo:

 - Avoid write of uninitialized memory when generating PERF_RECORD_MMAP*
   records.

 - Fix 'perf top' BPF support related crash with perf_event_paranoid=3 +
   kptr_restrict.

 - Validate raw event with sysfs exported format bits.

 - Fix waipid on SIGCHLD delivery bugs in 'perf daemon'.

 - Change to use bash for daemon test on Debian, where the default is
   dash and thus fails for use of bashisms in this test.

 - Fix memory leak in vDSO found using ASAN.

 - Remove now useless (due to the fact that BPF now supports static
   vars) failing sub test "BPF relocation checker".

 - Fix auxtrace queue conflict.

 - Sync linux/kvm.h with the kernel sources.

* tag 'perf-tools-fixes-for-v5.12-2020-03-28' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
  perf test: Change to use bash for daemon test
  perf record: Fix memory leak in vDSO found using ASAN
  perf test: Remove now useless failing sub test "BPF relocation checker"
  perf daemon: Return from kill functions
  perf daemon: Force waipid for all session on SIGCHLD delivery
  perf top: Fix BPF support related crash with perf_event_paranoid=3 + kptr_restrict
  perf pmu: Validate raw event with sysfs exported format bits
  perf synthetic events: Avoid write of uninitialized memory when generating PERF_RECORD_MMAP* records
  tools headers UAPI: Sync linux/kvm.h with the kernel sources
  perf synthetic-events: Fix uninitialized 'kernel_thread' variable
  perf auxtrace: Fix auxtrace queue conflict
parents 3fef15f8 1dc481c0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1154,6 +1154,7 @@ struct kvm_x86_mce {
#define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR	(1 << 0)
#define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL	(1 << 1)
#define KVM_XEN_HVM_CONFIG_SHARED_INFO		(1 << 2)
#define KVM_XEN_HVM_CONFIG_RUNSTATE		(1 << 3)

struct kvm_xen_hvm_config {
	__u32 flags;
@@ -1621,12 +1622,24 @@ struct kvm_xen_vcpu_attr {
	union {
		__u64 gpa;
		__u64 pad[8];
		struct {
			__u64 state;
			__u64 state_entry_time;
			__u64 time_running;
			__u64 time_runnable;
			__u64 time_blocked;
			__u64 time_offline;
		} runstate;
	} u;
};

/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO	0x0
#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO	0x1
#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR	0x2
#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT	0x3
#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA	0x4
#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST	0x5

/* Secure Encrypted Virtualization command */
enum sev_cmd_id {
+33 −24
Original line number Diff line number Diff line
@@ -402,17 +402,26 @@ static pid_t handle_signalfd(struct daemon *daemon)
	int status;
	pid_t pid;

	/*
	 * Take signal fd data as pure signal notification and check all
	 * the sessions state. The reason is that multiple signals can get
	 * coalesced in kernel and we can receive only single signal even
	 * if multiple SIGCHLD were generated.
	 */
	err = read(daemon->signal_fd, &si, sizeof(struct signalfd_siginfo));
	if (err != sizeof(struct signalfd_siginfo))
	if (err != sizeof(struct signalfd_siginfo)) {
		pr_err("failed to read signal fd\n");
		return -1;
	}

	list_for_each_entry(session, &daemon->sessions, list) {
		if (session->pid == -1)
			continue;

		if (session->pid != (int) si.ssi_pid)
		pid = waitpid(session->pid, &status, WNOHANG);
		if (pid <= 0)
			continue;

		pid = waitpid(session->pid, &status, 0);
		if (pid == session->pid) {
		if (WIFEXITED(status)) {
			pr_info("session '%s' exited, status=%d\n",
				session->name, WEXITSTATUS(status));
@@ -426,11 +435,9 @@ static pid_t handle_signalfd(struct daemon *daemon)
			pr_info("session '%s' Unexpected status (0x%x)\n",
				session->name, status);
		}
		}

		session->state = KILL;
		session->pid = -1;
		return pid;
	}

	return 0;
@@ -443,7 +450,6 @@ static int daemon_session__wait(struct daemon_session *session, struct daemon *d
		.fd	= daemon->signal_fd,
		.events	= POLLIN,
	};
	pid_t wpid = 0, pid = session->pid;
	time_t start;

	start = time(NULL);
@@ -452,7 +458,7 @@ static int daemon_session__wait(struct daemon_session *session, struct daemon *d
		int err = poll(&pollfd, 1, 1000);

		if (err > 0) {
			wpid = handle_signalfd(daemon);
			handle_signalfd(daemon);
		} else if (err < 0) {
			perror("failed: poll\n");
			return -1;
@@ -460,7 +466,7 @@ static int daemon_session__wait(struct daemon_session *session, struct daemon *d

		if (start + secs < time(NULL))
			return -1;
	} while (wpid != pid);
	} while (session->pid != -1);

	return 0;
}
@@ -902,7 +908,9 @@ static void daemon_session__kill(struct daemon_session *session,
			daemon_session__signal(session, SIGKILL);
			break;
		default:
			break;
			pr_err("failed to wait for session %s\n",
			       session->name);
			return;
		}
		how++;

@@ -955,7 +963,8 @@ static void daemon__kill(struct daemon *daemon)
			daemon__signal(daemon, SIGKILL);
			break;
		default:
			break;
			pr_err("failed to wait for sessions\n");
			return;
		}
		how++;

@@ -1344,7 +1353,7 @@ static int __cmd_start(struct daemon *daemon, struct option parent_options[],
		close(sock_fd);
	if (conf_fd != -1)
		close(conf_fd);
	if (conf_fd != -1)
	if (signal_fd != -1)
		close(signal_fd);

	pr_info("daemon exited\n");
+1 −8
Original line number Diff line number Diff line
@@ -99,13 +99,6 @@ static struct {
		.expect_result	  = (NR_ITERS + 1) / 4,
	},
#endif
	{
		.prog_id	  = LLVM_TESTCASE_BPF_RELOCATION,
		.desc		  = "BPF relocation checker",
		.name		  = "[bpf_relocation_test]",
		.msg_compile_fail = "fix 'perf test LLVM' first",
		.msg_load_fail	  = "libbpf error when dealing with relocation",
	},
};

static int do_test(struct bpf_object *obj, int (*func)(void),
+1 −1
Original line number Diff line number Diff line
#!/bin/sh
#!/bin/bash
# daemon operations
# SPDX-License-Identifier: GPL-2.0

+0 −4
Original line number Diff line number Diff line
@@ -298,10 +298,6 @@ static int auxtrace_queues__queue_buffer(struct auxtrace_queues *queues,
		queue->set = true;
		queue->tid = buffer->tid;
		queue->cpu = buffer->cpu;
	} else if (buffer->cpu != queue->cpu || buffer->tid != queue->tid) {
		pr_err("auxtrace queue conflict: cpu %d, tid %d vs cpu %d, tid %d\n",
		       queue->cpu, queue->tid, buffer->cpu, buffer->tid);
		return -EINVAL;
	}

	buffer->buffer_nr = queues->next_buffer_nr++;
Loading