The buffer used for verifying SVE Z registers allocated enough space for
16 maximally sized registers rather than 32 due to using the macro for the
number of P registers. In practice this didn't matter since for historical
reasons the maximum VQ defined in the ABI is greater the architectural
maximum so we will always allocate more space than is needed even with
emulated platforms implementing the architectural maximum. Still, we should
use the right define.
Signed-off-by: Mark Brown <broonie(a)kernel.org>
---
tools/testing/selftests/arm64/abi/syscall-abi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/arm64/abi/syscall-abi.c b/tools/testing/selftests/arm64/abi/syscall-abi.c
index b632bfe9e022..95229fa73232 100644
--- a/tools/testing/selftests/arm64/abi/syscall-abi.c
+++ b/tools/testing/selftests/arm64/abi/syscall-abi.c
@@ -113,8 +113,8 @@ static int check_fpr(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
}
static uint8_t z_zero[__SVE_ZREG_SIZE(SVE_VQ_MAX)];
-uint8_t z_in[SVE_NUM_PREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)];
-uint8_t z_out[SVE_NUM_PREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)];
+uint8_t z_in[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)];
+uint8_t z_out[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)];
static void setup_z(struct syscall_cfg *cfg, int sve_vl, int sme_vl,
uint64_t svcr)
--
2.30.2
Hi Paul,
as previously promised, here comes the nolibc update which introduces the
minimal self-test infrastructure that aims at being reasonably easy to
expand further.
It's based on your branch "dev.2022.06.30b" that contains the previous
minor fixes that aimed at addressing Linus' concerns about the build
process inconsistencies.
The way it works tries to mimmick as much as possible the regular build
process, so that it reuses the same ARCH, CC, CROSS_COMPILE to build the
test program, that will be embedded into an initramfs and the kernel is
(re)built with that initramfs. Then you can decide to run that kernel
under QEMU for the supported archs, and the output of the tests appears
in an output text file in a format that's easily greppable and diffable.
A single target "run" does everything.
By default it will reuse your existing .config (so that developers
continue to use their regular config handling), though it can also
create a known-to-work defconfig for each arch. The reason behind this
is that it took me a moment to figure certain defconfig + machine name
combinations and I found it better to put them there once for all.
I've successfully tested it on arm, arm64, i386, x86_64. riscv64 works
except two syscalls which return unexpected errors, and mips segfaults
in sbrk(). I don't know why yet, but this proves that it's worth having
such a test.
There are not that many tests yet (71), those that have to run can be
filtered either from the program's command line or from a NOLIBC_TEST
environment variable so that it's possible to skip broken ones or to
focus on a few ranges only.
Tests are numerically numbered, and are conveniently handled in a
switch/case statement so that a relative line number assigns the number
to the test. That's convenient because the vast majority of syscall tests
are one-liners. This sometimes slightly upsets check-patch when lines get
moderately long but that significantly improves legibility.
There are expectation for both successes and failures (e.g. -1 ENOTDIR).
I'm sure this can be improved later (and that's the goal). Right now it
covers two test families:
- syscalls
- stdlib (str* functions mostly)
I suspect that over time we might want to split syscalls into different
parts (e.g. core, fs, etc maybe) but I could be wrong.
The program can automatically modulate QEMU's return value on x86 when
QEMU is run with the appropriate options, but for now I'm not using it
as I felt like it didn't bring much value, and the output is more useful.
That's debatable, and maybe some might want to use it in bisect scripts
for example. It's too early to say IMHO.
Oh, I also arranged the code so that the test also builds with glibc. I
noticed that when adding a new test that fails, sometimes it's convenient
to see if it's the nolibc part that's broken or the test. I don't find
this critical but the required includes and ifdefs are there so that it
should be easy to maintain over time as well.
I'm obviously interested in comments, but really, I don't want to
overdesign something for a first step, it remains a very modest test
program and I'd like that it remains easy to hack on it and to contribute
new tests that are deemed useful.
I'm CCing the few who already contributed some patches and/or expressed
interest, as well as Linus who had a first bad experience when trying to
test it, hoping this one will be better. I'm pasting below [1] a copy of
a test on x86_64 below, that's summed up as "71 test(s) passed" at the
end of the "run" target.
If there's no objection, it would be nice to have this with your current
series, as it definitely helps spot and fix the bugs. In parallel I'll see
if I can figure the problems with the two tests that fail each on a
specific arch and I might possibly have a few extra fixes for the current
nolibc.
Thank you!
Willy
[1] example output
----8<----
Running test 'syscall'
0 getpid = 1 [OK]
1 getppid = 0 [OK]
5 getpgid_self = 0 [OK]
6 getpgid_bad = -1 ESRCH [OK]
7 kill_0 = 0 [OK]
8 kill_CONT = 0 [OK]
9 kill_BADPID = -1 ESRCH [OK]
10 sbrk = 0 [OK]
11 brk = 0 [OK]
12 chdir_root = 0 [OK]
13 chdir_dot = 0 [OK]
14 chdir_blah = -1 ENOENT [OK]
15 chmod_net = 0 [OK]
16 chmod_self = -1 EPERM [OK]
17 chown_self = -1 EPERM [OK]
18 chroot_root = 0 [OK]
19 chroot_blah = -1 ENOENT [OK]
20 chroot_exe = -1 ENOTDIR [OK]
21 close_m1 = -1 EBADF [OK]
22 close_dup = 0 [OK]
23 dup_0 = 3 [OK]
24 dup_m1 = -1 EBADF [OK]
25 dup2_0 = 100 [OK]
26 dup2_m1 = -1 EBADF [OK]
27 dup3_0 = 100 [OK]
28 dup3_m1 = -1 EBADF [OK]
29 execve_root = -1 EACCES [OK]
30 getdents64_root = 120 [OK]
31 getdents64_null = -1 ENOTDIR [OK]
32 gettimeofday_null = 0 [OK]
38 ioctl_tiocinq = 0 [OK]
39 ioctl_tiocinq = 0 [OK]
40 link_root1 = -1 EEXIST [OK]
41 link_blah = -1 ENOENT [OK]
42 link_dir = -1 EPERM [OK]
43 link_cross = -1 EXDEV [OK]
44 lseek_m1 = -1 EBADF [OK]
45 lseek_0 = -1 ESPIPE [OK]
46 mkdir_root = -1 EEXIST [OK]
47 open_tty = 3 [OK]
48 open_blah = -1 ENOENT [OK]
49 poll_null = 0 [OK]
50 poll_stdout = 1 [OK]
51 poll_fault = -1 EFAULT [OK]
52 read_badf = -1 EBADF [OK]
53 sched_yield = 0 [OK]
54 select_null = 0 [OK]
55 select_stdout = 1 [OK]
56 select_fault = -1 EFAULT [OK]
57 stat_blah = -1 ENOENT [OK]
58 stat_fault = -1 EFAULT [OK]
59 symlink_root = -1 EEXIST [OK]
60 unlink_root = -1 EISDIR [OK]
61 unlink_blah = -1 ENOENT [OK]
62 wait_child = -1 ECHILD [OK]
63 waitpid_min = -1 ESRCH [OK]
64 waitpid_child = -1 ECHILD [OK]
65 write_badf = -1 EBADF [OK]
66 write_zero = 0 [OK]
Errors during this test: 0
Running test 'stdlib'
0 getenv_TERM = <linux> [OK]
1 getenv_blah = <(null)> [OK]
2 setcmp_blah_blah = 0 [OK]
3 setcmp_blah_blah2 = -50 [OK]
4 setncmp_blah_blah = 0 [OK]
5 setncmp_blah_blah4 = 0 [OK]
6 setncmp_blah_blah5 = -53 [OK]
7 setncmp_blah_blah6 = -54 [OK]
8 strchr_foobar_o = <oobar> [OK]
9 strchr_foobar_z = <(null)> [OK]
10 strrchr_foobar_o = <obar> [OK]
11 strrchr_foobar_z = <(null)> [OK]
Errors during this test: 0
Total number of errors: 0
---->8----
--
Willy Tarreau (17):
tools/nolibc: make argc 32-bit in riscv startup code
tools/nolibc: fix build warning in sys_mmap() when my_syscall6 is not
defined
tools/nolibc: make sys_mmap() automatically use the right __NR_mmap
definition
selftests/nolibc: add basic infrastructure to ease creation of nolibc
tests
selftests/nolibc: support a test definition format
selftests/nolibc: implement a few tests for various syscalls
selftests/nolibc: add a few tests for some stdlib functions
selftests/nolibc: exit with poweroff on success when getpid() == 1
selftests/nolibc: on x86, support exiting with isa-debug-exit
selftests/nolibc: recreate and populate /dev and /proc if missing
selftests/nolibc: condition some tests on /proc existence
selftests/nolibc: support glibc as well
selftests/nolibc: add a "kernel" target to build the kernel with the
initramfs
selftests/nolibc: add a "defconfig" target
selftests/nolibc: add a "run" target to start the kernel in QEMU
selftests/nolibc: "sysroot" target installs a local copy of the
sysroot
selftests/nolibc: add a "help" target
MAINTAINERS | 1 +
tools/include/nolibc/arch-riscv.h | 2 +-
tools/include/nolibc/sys.h | 4 +-
tools/testing/selftests/nolibc/Makefile | 135 ++++
tools/testing/selftests/nolibc/nolibc-test.c | 757 +++++++++++++++++++
5 files changed, 896 insertions(+), 3 deletions(-)
create mode 100644 tools/testing/selftests/nolibc/Makefile
create mode 100644 tools/testing/selftests/nolibc/nolibc-test.c
--
2.17.5
On Tue, Jul 19, 2022 at 10:42 PM Karl MacMillan
<karl(a)bigbadwolfsecurity.com> wrote:
> On Thu, Jul 7, 2022 at 6:34 PM Frederick Lawler <fred(a)cloudflare.com> wrote:
>>
>> Unprivileged user namespace creation is an intended feature to enable
>> sandboxing, however this feature is often used to as an initial step to
>> perform a privilege escalation attack.
>>
>> This patch implements a new namespace { userns_create } access control
>> permission to restrict which domains allow or deny user namespace
>> creation. This is necessary for system administrators to quickly protect
>> their systems while waiting for vulnerability patches to be applied.
>>
>> This permission can be used in the following way:
>>
>> allow domA_t domB_t : namespace { userns_create };
>
>
> Isn’t this actually domA_t domA_t : namespace . . .
>
> I got confused reading this initially trying to figure out what the second domain type would be, but looking at the code cleared that up.
Ah, good catch, thanks Karl!
--
paul-moore.com
Run_wrapper.rst was missing some command line arguments. Added
additional args in the file. Included all initial review comments.
Signed-off-by: Sadiya Kazi <sadiyakazi(a)google.com>
---
Documentation/dev-tools/kunit/run_wrapper.rst | 48 +++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/Documentation/dev-tools/kunit/run_wrapper.rst b/Documentation/dev-tools/kunit/run_wrapper.rst
index 5e560f2c5fca..91f5dda36e83 100644
--- a/Documentation/dev-tools/kunit/run_wrapper.rst
+++ b/Documentation/dev-tools/kunit/run_wrapper.rst
@@ -257,3 +257,51 @@ command line arguments:
added or modified. Instead, enable all tests
which have satisfied dependencies by adding
``CONFIG_KUNIT_ALL_TESTS=y`` to your ``.kunitconfig``.
+- ``--kunitconfig``: Specifies the path to the ``.kunitconfig`` file.
+ This Kconfig fragment enables KUnit tests. The "/.kunitconfig" gets
+ appended to the path specified. For example, If a directory path "lib/kunit"
+ is given, the complete path will be "lib/kunit/.kunitconfig".
+
+- ``--kconfig_add``: Specifies additional configuration options to be
+ appended to the ``.kunitconfig`` file. For example, ``CONFIG_KASAN=y``.
+
+- ``--arch``: Runs tests with the specified architecture. The architecture
+ specified must match the string passed to the ARCH make parameter.
+ For example, i386, x86_64, arm, um, etc. Non-UML architectures run on QEMU.
+ Default to 'um'.
+
+- ``--cross_compile``: Specifies the Kbuild toolchain. It passes the
+ same argument as passed to the ``CROSS_COMPILE`` variable used by
+ Kbuild. This will be the prefix for the toolchain
+ binaries such as GCC. For example:
+
+ - ``sparc64-linux-gnu`` if we have the sparc toolchain installed on
+ our system.
+
+ - ``$HOME/toolchains/microblaze/gcc-9.2.0-nolibc/microblaze-linux/bin/microblaze-linux``
+ if we have downloaded the microblaze toolchain from the 0-day
+ website to a specified path in our home directory called toolchains.
+
+- ``--qemu_config``: Specifies the path to the file containing a
+ custom qemu architecture definition. This should be a python file
+ containing a QemuArchParams object.
+
+- ``--qemu_args``: Specifies additional QEMU arguments, for example, "-smp 8".
+
+- ``--jobs``: Specifies the number of jobs (commands) to run simultaneously.
+ By default, this is set to the number of cores on your system.
+
+- ``--timeout``: Specifies the maximum number of seconds allowed for all tests to run.
+ This does not include the time taken to build the tests.
+
+- ``--kernel_args``: Specifies the kernel command-line arguments. Might be repeated.
+
+- ``--run_isolated``: If set, boots the kernel for each individual suite/test.
+ This is useful for debugging a non-hermetic test, one that
+ might pass/fail based on what ran before it.
+
+- ``--raw_output``: If set, generates unformatted output from kernel.
+ If set to ``--raw_output=kunit``, filters to just KUnit output.
+
+- ``--json``: If set, it stores the test results in a JSON format and prints to stdout or
+ saves to a file if a filename is specified.
--
2.37.0.170.g444d1eabd0-goog
Hello Dmitry Safonov,
The patch bc2652b7ae1e: "selftest/net/xfrm: Add test for ipsec
tunnel" from Sep 21, 2020, leads to the following Smatch static
checker warning:
tools/testing/selftests/net/ipsec.c:2294 main()
warn: impossible condition '(nr_process == 9223372036854775807) => (0-4294967295 == s64max)'
tools/testing/selftests/net/ipsec.c
2278 int main(int argc, char **argv)
2279 {
2280 unsigned int nr_process = 1;
2281 int route_sock = -1, ret = KSFT_SKIP;
2282 int test_desc_fd[2];
2283 uint32_t route_seq;
2284 unsigned int i;
2285
2286 if (argc > 2)
2287 exit_usage(argv);
2288
2289 if (argc > 1) {
2290 char *endptr;
2291
2292 errno = 0;
2293 nr_process = strtol(argv[1], &endptr, 10);
--> 2294 if ((errno == ERANGE && (nr_process == LONG_MAX || nr_process == LONG_MIN))
nr_process is a u32 so it can't be LONG_MIN/MAX. Do we even need to test
this or could we just fall through to the the > MAX_PROCESSES warning?
2295 || (errno != 0 && nr_process == 0)
2296 || (endptr == argv[1]) || (*endptr != '\0')) {
2297 printk("Failed to parse [nr_process]");
2298 exit_usage(argv);
2299 }
2300
2301 if (nr_process > MAX_PROCESSES || !nr_process) {
2302 printk("nr_process should be between [1; %u]",
2303 MAX_PROCESSES);
2304 exit_usage(argv);
2305 }
2306 }
2307
regards,
dan carpenter
The snprintf() function returns the number of bytes which *would*
have been copied if there were space. In other words, it can be
> sizeof(pin_path).
Fixes: c0fa1b6c3efc ("bpf: btf: Add BTF tests")
Signed-off-by: Dan Carpenter <dan.carpenter(a)oracle.com>
---
tools/testing/selftests/bpf/prog_tests/btf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c
index 941b0100bafa..ef6528b8084c 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf.c
@@ -5338,7 +5338,7 @@ static void do_test_pprint(int test_num)
ret = snprintf(pin_path, sizeof(pin_path), "%s/%s",
"/sys/fs/bpf", test->map_name);
- if (CHECK(ret == sizeof(pin_path), "pin_path %s/%s is too long",
+ if (CHECK(ret >= sizeof(pin_path), "pin_path %s/%s is too long",
"/sys/fs/bpf", test->map_name)) {
err = -1;
goto done;
--
2.35.1
Hi,
and after a little bit of time, here comes the v6 of the HID-BPF series.
Again, for a full explanation of HID-BPF, please refer to the last patch
in this series (23/23).
This version sees some improvements compared to v5 on top of the
usual addressing of the previous comments:
- now I think every eBPF core change has a matching selftest added
- the kfuncs declared in syscall can now actually access the memory of
the context
- the code to retrieve the BTF ID of the various HID hooks is much
simpler (just a plain use of the BTF_ID() API instead of
loading/unloading of a tracing program)
- I also added my HID Surface Dial example that I use locally to provide
a fuller example to users
Cheers,
Benjamin
Benjamin Tissoires (23):
selftests/bpf: fix config for CLS_BPF
bpf/verifier: allow kfunc to read user provided context
bpf/verifier: do not clear meta in check_mem_size
selftests/bpf: add test for accessing ctx from syscall program type
bpf/verifier: allow kfunc to return an allocated mem
selftests/bpf: Add tests for kfunc returning a memory pointer
bpf: prepare for more bpf syscall to be used from kernel and user
space.
libbpf: add map_get_fd_by_id and map_delete_elem in light skeleton
HID: core: store the unique system identifier in hid_device
HID: export hid_report_type to uapi
HID: convert defines of HID class requests into a proper enum
HID: initial BPF implementation
selftests/bpf: add tests for the HID-bpf initial implementation
HID: bpf: allocate data memory for device_event BPF programs
selftests/bpf/hid: add test to change the report size
HID: bpf: introduce hid_hw_request()
selftests/bpf: add tests for bpf_hid_hw_request
HID: bpf: allow to change the report descriptor
selftests/bpf: add report descriptor fixup tests
selftests/bpf: Add a test for BPF_F_INSERT_HEAD
samples/bpf: add new hid_mouse example
HID: bpf: add Surface Dial example
Documentation: add HID-BPF docs
Documentation/hid/hid-bpf.rst | 512 +++++++++
Documentation/hid/index.rst | 1 +
drivers/hid/Kconfig | 2 +
drivers/hid/Makefile | 2 +
drivers/hid/bpf/Kconfig | 19 +
drivers/hid/bpf/Makefile | 11 +
drivers/hid/bpf/entrypoints/Makefile | 88 ++
drivers/hid/bpf/entrypoints/README | 4 +
drivers/hid/bpf/entrypoints/entrypoints.bpf.c | 66 ++
.../hid/bpf/entrypoints/entrypoints.lskel.h | 682 ++++++++++++
drivers/hid/bpf/hid_bpf_dispatch.c | 554 ++++++++++
drivers/hid/bpf/hid_bpf_dispatch.h | 28 +
drivers/hid/bpf/hid_bpf_jmp_table.c | 577 ++++++++++
drivers/hid/hid-core.c | 49 +-
include/linux/bpf.h | 10 +-
include/linux/btf.h | 14 +
include/linux/hid.h | 38 +-
include/linux/hid_bpf.h | 145 +++
include/uapi/linux/hid.h | 26 +-
include/uapi/linux/hid_bpf.h | 25 +
kernel/bpf/btf.c | 67 +-
kernel/bpf/syscall.c | 10 +-
kernel/bpf/verifier.c | 67 +-
net/bpf/test_run.c | 23 +
samples/bpf/.gitignore | 2 +
samples/bpf/Makefile | 27 +
samples/bpf/hid_mouse.bpf.c | 134 +++
samples/bpf/hid_mouse.c | 150 +++
samples/bpf/hid_surface_dial.bpf.c | 161 +++
samples/bpf/hid_surface_dial.c | 216 ++++
tools/include/uapi/linux/hid.h | 62 ++
tools/include/uapi/linux/hid_bpf.h | 25 +
tools/lib/bpf/skel_internal.h | 23 +
tools/testing/selftests/bpf/Makefile | 5 +-
tools/testing/selftests/bpf/config | 5 +-
tools/testing/selftests/bpf/prog_tests/hid.c | 990 ++++++++++++++++++
.../selftests/bpf/prog_tests/kfunc_call.c | 68 ++
tools/testing/selftests/bpf/progs/hid.c | 206 ++++
.../selftests/bpf/progs/kfunc_call_test.c | 116 ++
39 files changed, 5150 insertions(+), 60 deletions(-)
create mode 100644 Documentation/hid/hid-bpf.rst
create mode 100644 drivers/hid/bpf/Kconfig
create mode 100644 drivers/hid/bpf/Makefile
create mode 100644 drivers/hid/bpf/entrypoints/Makefile
create mode 100644 drivers/hid/bpf/entrypoints/README
create mode 100644 drivers/hid/bpf/entrypoints/entrypoints.bpf.c
create mode 100644 drivers/hid/bpf/entrypoints/entrypoints.lskel.h
create mode 100644 drivers/hid/bpf/hid_bpf_dispatch.c
create mode 100644 drivers/hid/bpf/hid_bpf_dispatch.h
create mode 100644 drivers/hid/bpf/hid_bpf_jmp_table.c
create mode 100644 include/linux/hid_bpf.h
create mode 100644 include/uapi/linux/hid_bpf.h
create mode 100644 samples/bpf/hid_mouse.bpf.c
create mode 100644 samples/bpf/hid_mouse.c
create mode 100644 samples/bpf/hid_surface_dial.bpf.c
create mode 100644 samples/bpf/hid_surface_dial.c
create mode 100644 tools/include/uapi/linux/hid.h
create mode 100644 tools/include/uapi/linux/hid_bpf.h
create mode 100644 tools/testing/selftests/bpf/prog_tests/hid.c
create mode 100644 tools/testing/selftests/bpf/progs/hid.c
--
2.36.1
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: 61e52f1630f5 ("KVM: selftests: Add a test for KVM_RUN+rseq to detect task migration bugs")
Suggested-by: Sean Christopherson <seanjc(a)google.com>
Signed-off-by: Gavin Shan <gshan(a)redhat.com>
Reviewed-by: Oliver Upton <oliver.upton(a)linux.dev>
---
v4: Pick the code change as Sean suggested.
---
tools/testing/selftests/kvm/rseq_test.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
index 4158da0da2bb..2237d1aac801 100644
--- a/tools/testing/selftests/kvm/rseq_test.c
+++ b/tools/testing/selftests/kvm/rseq_test.c
@@ -82,8 +82,9 @@ static int next_cpu(int cpu)
return cpu;
}
-static void *migration_worker(void *ign)
+static void *migration_worker(void *__rseq_tid)
{
+ pid_t rseq_tid = (pid_t)(unsigned long)__rseq_tid;
cpu_set_t allowed_mask;
int r, i, cpu;
@@ -106,7 +107,7 @@ static void *migration_worker(void *ign)
* stable, i.e. while changing affinity is in-progress.
*/
smp_wmb();
- r = sched_setaffinity(0, sizeof(allowed_mask), &allowed_mask);
+ r = sched_setaffinity(rseq_tid, sizeof(allowed_mask), &allowed_mask);
TEST_ASSERT(!r, "sched_setaffinity failed, errno = %d (%s)",
errno, strerror(errno));
smp_wmb();
@@ -231,7 +232,8 @@ int main(int argc, char *argv[])
vm = vm_create_default(VCPU_ID, 0, guest_code);
ucall_init(vm, NULL);
- pthread_create(&migration_thread, NULL, migration_worker, 0);
+ pthread_create(&migration_thread, NULL, migration_worker,
+ (void *)(unsigned long)gettid());
for (i = 0; !done; i++) {
vcpu_run(vm, VCPU_ID);
--
2.23.0