linux-stable/tools
Gavin Shan 4c728788a7 KVM: selftests: Fix target thread to be migrated in rseq_test
commit e923b0537d upstream.

In rseq_test, there are two threads, which are vCPU thread and migration
worker separately. Unfortunately, the test has the wrong PID passed to
sched_setaffinity() in the migration worker. It forces migration on the
migration worker because zeroed PID represents the calling thread, which
is the migration worker itself. It means the vCPU thread is never enforced
to migration and it can migrate at any time, which eventually leads to
failure as the following logs show.

  host# uname -r
  5.19.0-rc6-gavin+
  host# # cat /proc/cpuinfo | grep processor | tail -n 1
  processor    : 223
  host# pwd
  /home/gavin/sandbox/linux.main/tools/testing/selftests/kvm
  host# for i in `seq 1 100`; do \
        echo "--------> $i"; ./rseq_test; done
  --------> 1
  --------> 2
  --------> 3
  --------> 4
  --------> 5
  --------> 6
  ==== Test Assertion Failure ====
    rseq_test.c:265: rseq_cpu == cpu
    pid=3925 tid=3925 errno=4 - Interrupted system call
       1  0x0000000000401963: main at rseq_test.c:265 (discriminator 2)
       2  0x0000ffffb044affb: ?? ??:0
       3  0x0000ffffb044b0c7: ?? ??:0
       4  0x0000000000401a6f: _start at ??:?
    rseq CPU = 4, sched CPU = 27

Fix the issue by passing correct parameter, TID of the vCPU thread, to
sched_setaffinity() in the migration worker.

Fixes: 61e52f1630 ("KVM: selftests: Add a test for KVM_RUN+rseq to detect task migration bugs")
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Message-Id: <20220719020830.3479482-1-gshan@redhat.com>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:28:13 +02:00
..
accounting delayacct: track delays from memory compact 2022-01-20 08:52:55 +02:00
arch tools headers cpufeatures: Sync with the kernel sources 2022-07-23 12:56:59 +02:00
bootconfig
bpf Networking fixes for 5.18-rc2, including fixes from bpf and netfilter 2022-04-07 19:01:47 -10:00
build perf build: Fix btf__load_from_kernel_by_id() feature check 2022-06-09 10:30:38 +02:00
cgroup tools/cgroup/slabinfo: update to work with struct slab 2022-02-21 11:34:49 +01:00
counter kbuild: replace $(if A,A,B) with $(or A,B) 2022-02-15 12:25:56 +09:00
debugging
edid
firewire
firmware
gpio kbuild: replace $(if A,A,B) with $(or A,B) 2022-02-15 12:25:56 +09:00
hv kbuild: replace $(if A,A,B) with $(or A,B) 2022-02-15 12:25:56 +09:00
iio Kbuild updates for v5.18 2022-03-31 11:59:03 -07:00
include objtool: Re-add UNWIND_HINT_{SAVE_RESTORE} 2022-07-23 12:56:53 +02:00
io_uring
kvm/kvm_stat
laptop
leds
lib libbpf: Fix logic for finding matching program for CO-RE relocation 2022-06-09 10:30:03 +02:00
memory-model tools/memory-model/README: Update klitmus7 compat table 2022-06-06 08:48:56 +02:00
objtool x86/retbleed: Add fine grained Kconfig knobs 2022-07-23 12:56:56 +02:00
pci kbuild: replace $(if A,A,B) with $(or A,B) 2022-02-15 12:25:56 +09:00
pcmcia
perf perf tests: Fix Convert perf time to TSC test for hybrid 2022-07-29 17:28:03 +02:00
power tools/power turbostat: fix ICX DRAM power numbers 2022-06-09 10:29:35 +02:00
rcu
scripts Kbuild updates for v5.18 2022-03-31 11:59:03 -07:00
spi kbuild: replace $(if A,A,B) with $(or A,B) 2022-02-15 12:25:56 +09:00
testing KVM: selftests: Fix target thread to be migrated in rseq_test 2022-07-29 17:28:13 +02:00
thermal/tmon
time
tracing rtla/Makefile: Properly handle dependencies 2022-06-14 18:45:03 +02:00
usb kbuild: replace $(if A,A,B) with $(or A,B) 2022-02-15 12:25:56 +09:00
virtio tools/virtio: compile with -pthread 2022-03-28 16:52:59 -04:00
vm tools/vm/page_owner_sort.c: remove -c option 2022-04-01 11:46:09 -07:00
wmi
Makefile