| /* | |
| * SPDX-License-Identifier: GPL-2.0-or-later | |
| * | |
| * This test attempts to execute a magic syscall. The syscall test plugin | |
| * should intercept this and return an expected value. | |
| */ | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| int main(int argc, char *argv[]) | |
| { | |
| #ifdef SKIP | |
| return EXIT_SUCCESS; | |
| #endif | |
| /* | |
| * We cannot use a very large magic syscall number, because on some ISAs, | |
| * QEMU will treat it as an illegal instruction and trigger a critical | |
| * exception. For instance, on arm32, the syscall number cannot exceed | |
| * ARM_NR_BASE (0xf0000), as can be seen in | |
| * "linux-user/arm/cpu_loop.c:cpu_loop". | |
| * As well, some arch expect a minimum, like 4000 for mips 32 bits. | |
| * | |
| * Therefore, we pick 4096, which sits between those bounds. It is not | |
| * unused everywhere though: mips 32 bits numbers from 4000, so 4096 is its | |
| * getpriority. This test is unaffected because the filter also requires | |
| * the first argument to be 0x66CCFF, so a real syscall carrying this | |
| * number falls through untouched. This is just a test case, so replace | |
| * this number as needed in the future. | |
| * | |
| * The corresponding syscall filter is implemented in | |
| * "tests/tcg/plugins/syscall.c". | |
| */ | |
| long ret = syscall(4096, 0x66CCFF); | |
| if (ret != 0xFFCC66) { | |
| fprintf(stderr, "Error: unexpected syscall return value %ld\n", ret); | |
| return EXIT_FAILURE; | |
| } | |
| return EXIT_SUCCESS; | |
| } |