[Tests] SIGXCPU signal is unsupported
Test: setrlimit06 Purpose of test: This test sets cpu time limit for a process and check its behavior. After reaching the CPU time limit it checks the process got SGXCPU .
Console logs: [ SGX-LKL ] Calling app main: /ltp/testcases/kernel/syscalls/setrlimit/setrlimit06 tst_test.c:1106: INFO: Timeout per run is 0h 05m 00s tst_test.c:1125: INFO: No fork support Test was timing out. code snippet:
static void sighandler(int sig)
{
*end = sig;
}
static void setup(void)
{
SAFE_SIGNAL(SIGXCPU, sighandler);
end = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
}
pid = SAFE_FORK();
if (!pid) {
struct rlimit rlim = {
.rlim_cur = 2,
.rlim_max = 3,
};
TEST(setrlimit(RLIMIT_CPU, &rlim));
if (TST_RET == -1) {
tst_res(TFAIL | TTERRNO,
"setrlimit(RLIMIT_CPU) failed");
exit(1);
}
alarm(10);
while (1);
}
gdb
[[ LKL SYSC ]] [tid=1 ] openat 56 (-100, /ltp/testcases/kernel/syscalls/setrlimit/setrlimit06, 0, 0) = 5
[[ LKL SYSC ]] [tid=1 ] read 63 (5, 140734227468320, 452544, 0, 0, 0) = 452544
Loading symbols at base 0x7fff3da9c000...
add symbol table from file "/tmp/tmpg3m8a4la.so" at
.text_addr = 0x7fff3daa0470
.interp_addr = 0x7fff3da9c200
.gnu.hash_addr = 0x7fff3da9c220
.dynsym_addr = 0x7fff3da9c268
.dynstr_addr = 0x7fff3da9d270
.rela.dyn_addr = 0x7fff3da9d7b0
.rela.plt_addr = 0x7fff3da9ebf0
.init_addr = 0x7fff3da9fa78
.plt_addr = 0x7fff3da9fa90
.plt.got_addr = 0x7fff3daa0450
.fini_addr = 0x7fff3daaf353
.rodata_addr = 0x7fff3daaf360
.eh_frame_hdr_addr = 0x7fff3dab2bc8
.eh_frame_addr = 0x7fff3dab32b0
.ctors_addr = 0x7fff3dcb7bf8
.dtors_addr = 0x7fff3dcb7c08
.jcr_addr = 0x7fff3dcb7c18
.data.rel.ro_addr = 0x7fff3dcb7c20
.dynamic_addr = 0x7fff3dcb8958
.got_addr = 0x7fff3dcb8ad8
.data_addr = 0x7fff3dcb9000
.bss_addr = 0x7fff3dcb9200
[[ LKL SYSC ]] [tid=1 ] close 57 (5, 0, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] close 57 (4, 0, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] openat 56 (-100, /ltp/testcases/kernel/syscalls/setrlimit/setrlimit06, 0, 0) = 4
[[ LKL SYSC ]] [tid=1 ] prctl 167 (35, 13, 4, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] close 57 (4, 0, 0, 0, 0, 0) = 0
[[ SGX-LKL ]] libc_start_main_stage2(): Calling app main: /ltp/testcases/kernel/syscalls/setrlimit/setrlimit06
[[ LKL SYSC ]] [tid=1 ] getpid 172 (0, 0, 0, 0, 0, 0) = 36
[[ LKL SYSC ]] [tid=1 ] faccessat 48 (-100, 140734228004790, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] getpid 172 (0, 0, 0, 0, 0, 0) = 36
[[ LKL SYSC ]] [tid=1 ] openat 56 (-100, /dev/shm/ltp_setrlimit06_36, 194, 384) = 4
[[ LKL SYSC ]] [tid=1 ] fchmodat 53 (-100, 140734230139584, 438, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] ftruncate 46 (4, 4096, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] mmap 222 (0, 4096, 3, 1, 4, 0) = 140734270423040
[[ LKL SYSC ]] [tid=1 ] unlinkat 35 (-100, 140734230139584, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] close 57 (4, 0, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] rt_sigaction 134 (14, 140734278921040, 140734278921008, 8, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] rt_sigaction 134 (10, 140734278921040, 140734278921008, 8, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] ioctl 29 (2, 21523, 140734278919968, 0, 0, 0) = 0
tst_test.c:1106: INFO: Timeout per run is 0h 05m 00s
[[ LKL SYSC ]] [tid=1 ] writev 66 (2, 140734278919744, 2, 0, 0, 0) = 64
[[ LKL SYSC ]] [tid=1 ] getpid 172 (0, 0, 0, 0, 0, 0) = 36
[[ LKL SYSC ]] [tid=1 ] setitimer 103 (0, 140734278921408, 140734278921408, 0, 0, 0) = 0
tst_test.c:1125: INFO: No fork support
[[ LKL SYSC ]] [tid=1 ] writev 66 (2, 140734278919808, 2, 0, 0, 0) = 50
[[ LKL SYSC ]] [tid=1 ] rt_sigaction 134 (14, 140734278920944, 140734278920912, 8, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] rt_sigaction 134 (10, 140734278920944, 140734278920912, 8, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] rt_sigaction 134 (2, 140734278920944, 140734278920912, 8, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] setpgid 154 (0, 0, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] clock_gettime 113 (1, 140734230141648, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] getppid 173 (0, 0, 0, 0, 0, 0) = 1
[[ LKL SYSC ]] [tid=1 ] kill 129 (1, 10, 0, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] getpid 172 (0, 0, 0, 0, 0, 0) = 36
[[ LKL SYSC ]] [tid=1 ] rt_sigaction 134 (24, 140734278920976, 140734278920944, 8, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] rt_sigaction 134 (14, 140734278920976, 140734278920944, 8, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] getpid 172 (0, 0, 0, 0, 0, 0) = 36
[Switching to Thread 0x7fff90f9d700 (LWP 19753)]
Thread 9 "ENCLAVE" hit Breakpoint 1, setrlimit (resource=0,
rlim=0x7fff40b3ecc0) at src/misc/setrlimit.c:41
41 src/misc/setrlimit.c: No such file or directory.
(gdb) p rlim
$1 = (const struct rlimit *) 0x7fff40b3ecc0
(gdb) ptype rlim
type = const struct rlimit {
rlim_t rlim_cur;
rlim_t rlim_max;
} *
(gdb) p rlim.rlim_cur
$2 = 2
(gdb) p rlim.rlim_max
$3 = 3
(gdb) p *rlim
$4 = {rlim_cur = 2, rlim_max = 3}
(gdb) bt
#0 setrlimit (resource=0, rlim=0x7fff40b3ecc0) at src/misc/setrlimit.c:41
#1 0x00007fff3daa0786 in verify_setrlimit () at setrlimit06.c:75
#2 0x00007fff3daa516d in run_tests () at tst_test.c:932
#3 testrun () at tst_test.c:1022
#4 fork_testrun () at tst_test.c:1132
#5 0x00007fff3daa5c72 in tst_run_tcases (argc=<optimized out>,
argv=<optimized out>, self=self@entry=0x7fff3dcb9020 <test>)
at tst_test.c:1203
#6 0x00007fff3daa0500 in main (argc=<optimized out>, argv=<optimized out>)
at ../../../../include/tst_test.h:284
#7 0x00007fff00513432 in libc_start_main_stage2 (main=0x7fff3daa04f0 <main>,
argc=1, argv=0x7fff40b3ee98) at src/env/__libc_start_main.c:168
#8 0x00007fff00513391 in __libc_start_main (main=0x7fff3daa04f0 <main>,
argc=1, argv=0x7fff40b3ee98) at src/env/__libc_start_main.c:153
#9 0x00007fff3daa053e in _start_c (p=<optimized out>) at crt/crt1.c:17
#10 0x00007fff3daa0516 in _start ()
#11 0x0000000000000001 in ?? ()
#12 0x00007fff00b45920 in ?? ()
#13 0x0000000000000000 in ?? ()
(gdb) c
Continuing.
[[ LKL SYSC ]] [tid=1 ] prlimit64 261 (0, 0, 140734278921408, 0, 0, 0) = 0
[[ LKL SYSC ]] [tid=1 ] setitimer 103 (0, 140734278921360, 140734278921360, 0, 0, 0) = 0
^C
What do you mean ‘product’?
This is likely to be quite difficult to fix, because the LKL scheduler is not aware of the amount of CPU time that userspace threads consume. This should be added to the list of things that we are not able to provide full compatibility for.
Yes David. Just to clarify I was referring to ltp test classification. I will mark it as unsupported. Is there any other place where this should be documented?
@prp Updated. Please let us know if any other information is needed.
Signals such as SIGXCPU are unsupported because the LKL scheduler is currently unaware of the time that lthreads spent running. Addressing this issue would require a tighter integration of the lthread and LKL schedulers.
I think the most difficult bit of this is that we don't have time within the enclave at a granularity that's actually useful for this. If we did, then we could make the lthread scheduler record the time that each lthread runs for and then update the statistics in the LKL scheduler's switch-to routine to collect this when we switch away from a thread.
In the short term, we should make sure that this is a documented limitation of SGX-LKL. I don't anticipate this being a priority for any users.