mirror of
https://github.com/torvalds/linux.git
synced 2026-10-30 14:06:03 +01:00
- Fix several issues with seeding KVM's pRNG, and rework the pRNG APIs to that
the pRNG can be sanely used in host code, not just guest code.
- Add an IRQ test to validate virtual IRQ deliverty for IRQs wired up via
KVM_IRQFD + KVM_SET_GSI_ROUTING, with optional support for triggering IRQs
via writes to an assigned VFIO device.
- Add syscall wrappers to assert success on a variety of pthreads and CPU
affinity APIs.
- Set vCPU pthread affinity as early as possible to reduce contention issues
that were surfaced by PREEMPT_LAZY, which result in runtimes of over a
minute on large hosts, versus the expected ~5 seconds.
- Rework the PMU counters test to run each testcase using a single VM with
many vCPUs for each sub-testcase, instead of using a unique VM for each
sub-testcase. This cuts the runtime by ~20x.
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEKTobbabEP7vbhhN9OlYIJqCjN/0FAmp8yNoACgkQOlYIJqCj
N/2s+w/+KtexoVLUzAy5DwIpm2g0pHqPAm5me7lTj1IuKyPxCksmmskNu3Nrfpn+
0fp0QyB3gfUFscwKgqq8waLHBRyszQvTgfF43h/Bvu7QoNgoBViu9ybkd91REkSM
CZj6ltUiHYJ1AmyB2khc5kPisLdZvEewSr1A2I9PudaPDa7DlOzN7DOCq4yePYkq
4Bt7oFKDB/BH1Cv/QlCpUbseKLydBX8Zgd9QZy8bTqRdEeHywXfbKv1b1AkX8Vc+
C0puEKrnJ6gluBTERYZ8+ibLBdewt/Hr+JdqlVtVkjSF2esGAWW//RuDlRj2zRzl
MTj5BK8MXotmrHp0RZD+QTcG6JEOVM5XtRTstJP4taKV1jKXxHcCa3+9jOSFbcU1
0E7cklQOwbgXIGw/Tc2fQ1wHu2E4Ee/r7C29qGxx6xUZQ6krUYBqRUZMZ0e5isK1
GW2EPpb8AXC6+XaoNeCP2rPhu6mB+GhC2Q4k9pKWjasDTLes6CkBfDf/+i5+LEXk
oQ3UTP1qGqUmm1y5m9h7+jUy4CdlzIbcLIUUt4X0naNJbpJsZqRvX3D4SKLf/wtV
ZPmmih2ha01gnErm3Znn8rxIIodEiwwXIRSSKi1IzBmghOJzgSXtynMzXmwOaQtW
4vdT22Yf1ip3pREfvtbL0pPDdxaJI4ngmm8Ia/ORHLYFbJmA5aM=
=fs2O
-----END PGP SIGNATURE-----
Merge tag 'kvm-x86-selftests2-7.3' of https://github.com/kvm-x86/linux into HEAD
KVM selftests changes for 7.3, part 2
- Fix several issues with seeding KVM's pRNG, and rework the pRNG APIs to that
the pRNG can be sanely used in host code, not just guest code.
- Add an IRQ test to validate virtual IRQ deliverty for IRQs wired up via
KVM_IRQFD + KVM_SET_GSI_ROUTING, with optional support for triggering IRQs
via writes to an assigned VFIO device.
- Add syscall wrappers to assert success on a variety of pthreads and CPU
affinity APIs.
- Set vCPU pthread affinity as early as possible to reduce contention issues
that were surfaced by PREEMPT_LAZY, which result in runtimes of over a
minute on large hosts, versus the expected ~5 seconds.
- Rework the PMU counters test to run each testcase using a single VM with
many vCPUs for each sub-testcase, instead of using a unique VM for each
sub-testcase. This cuts the runtime by ~20x.
99 lines
2.2 KiB
C
99 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* tools/testing/selftests/kvm/lib/assert.c
|
|
*
|
|
* Copyright (C) 2018, Google LLC.
|
|
*/
|
|
#include "test_util.h"
|
|
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include "kselftest.h"
|
|
#include "kvm_syscalls.h"
|
|
|
|
#ifdef __GLIBC__
|
|
#include <execinfo.h>
|
|
|
|
/* Dumps the current stack trace to stderr. */
|
|
static void __attribute__((noinline)) test_dump_stack(void);
|
|
static void test_dump_stack(void)
|
|
{
|
|
/*
|
|
* Build and run this command:
|
|
*
|
|
* addr2line -s -e /proc/$PPID/exe -fpai {backtrace addresses} | \
|
|
* cat -n 1>&2
|
|
*
|
|
* Note that the spacing is different and there's no newline.
|
|
*/
|
|
size_t i;
|
|
size_t n = 20;
|
|
void *stack[n];
|
|
const char *addr2line = "addr2line -s -e /proc/$PPID/exe -fpai";
|
|
const char *pipeline = "|cat -n 1>&2";
|
|
char cmd[strlen(addr2line) + strlen(pipeline) +
|
|
/* N bytes per addr * 2 digits per byte + 1 space per addr: */
|
|
n * (((sizeof(void *)) * 2) + 1) +
|
|
/* Null terminator: */
|
|
1];
|
|
char *c = cmd;
|
|
|
|
n = backtrace(stack, n);
|
|
/*
|
|
* Skip the first 2 frames, which should be test_dump_stack() and
|
|
* test_assert(); both of which are declared noinline. Bail if the
|
|
* resulting stack trace would be empty. Otherwise, addr2line will block
|
|
* waiting for addresses to be passed in via stdin.
|
|
*/
|
|
if (n <= 2) {
|
|
fputs(" (stack trace empty)\n", stderr);
|
|
return;
|
|
}
|
|
|
|
c += sprintf(c, "%s", addr2line);
|
|
for (i = 2; i < n; i++)
|
|
c += sprintf(c, " %lx", ((unsigned long) stack[i]) - 1);
|
|
|
|
c += sprintf(c, "%s", pipeline);
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Wunused-result"
|
|
system(cmd);
|
|
#pragma GCC diagnostic pop
|
|
}
|
|
#else
|
|
static void test_dump_stack(void) {}
|
|
#endif
|
|
|
|
void __attribute__((noinline))
|
|
test_assert(bool exp, const char *exp_str,
|
|
const char *file, unsigned int line, const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
|
|
if (!(exp)) {
|
|
va_start(ap, fmt);
|
|
|
|
fprintf(stderr, "\n==== Test Assertion Failure ====\n"
|
|
" %s:%u: %s\n"
|
|
" pid=%d tid=%d errno=%d - %s\n",
|
|
file, line, exp_str, getpid(), kvm_gettid(),
|
|
errno, strerror(errno));
|
|
test_dump_stack();
|
|
if (fmt) {
|
|
fputs(" ", stderr);
|
|
vfprintf(stderr, fmt, ap);
|
|
fputs("\n", stderr);
|
|
}
|
|
va_end(ap);
|
|
|
|
if (errno == EACCES) {
|
|
print_skip("Access denied - Exiting");
|
|
exit(KSFT_SKIP);
|
|
}
|
|
exit(254);
|
|
}
|
|
|
|
return;
|
|
}
|