Lines Matching +full:1 +full:- +full:47

1 // SPDX-License-Identifier: GPL-2.0-only
3 * sigreturn.c - tests that x86 avoids Intel SYSRET pitfalls
4 * Copyright (c) 2014-2016 Andrew Lutomirski
43 err(1, "sigaction"); in sethandler()
53 err(1, "sigaction"); in clearhandler()
65 if (rip != ctx->uc_mcontext.gregs[REG_RIP]) { in sigsegv_for_sigreturn_test()
67 rip, (unsigned long)ctx->uc_mcontext.gregs[REG_RIP]); in sigsegv_for_sigreturn_test()
69 _exit(1); in sigsegv_for_sigreturn_test()
72 memcpy(&ctx->uc_mcontext.gregs, &initial_regs, sizeof(gregset_t)); in sigsegv_for_sigreturn_test()
81 memcpy(&initial_regs, &ctx->uc_mcontext.gregs, sizeof(gregset_t)); in sigusr1()
84 ctx->uc_mcontext.gregs[REG_RIP] = rip; in sigusr1()
85 ctx->uc_mcontext.gregs[REG_RCX] = rip; in sigusr1()
88 assert(ctx->uc_mcontext.gregs[REG_EFL] == in sigusr1()
89 ctx->uc_mcontext.gregs[REG_R11]); in sigusr1()
109 if (rip != ctx->uc_mcontext.gregs[REG_RIP]) { in sigsegv_for_fallthrough()
111 rip, (unsigned long)ctx->uc_mcontext.gregs[REG_RIP]); in sigsegv_for_fallthrough()
113 _exit(1); in sigsegv_for_fallthrough()
116 siglongjmp(jmpbuf, 1); in sigsegv_for_fallthrough()
121 void *new_address = (void *)(ip - 4096); in test_syscall_fallthrough_to()
129 if (ip <= (1UL << 47) - PAGE_SIZE) { in test_syscall_fallthrough_to()
130 err(1, "mremap to %p", new_address); in test_syscall_fallthrough_to()
138 errx(1, "mremap malfunctioned: asked for %p but got %p\n", in test_syscall_fallthrough_to()
144 if (sigsetjmp(jmpbuf, 1) == 0) { in test_syscall_fallthrough_to()
146 [syscall_insn] "rm" (ip - 2)); in test_syscall_fallthrough_to()
147 errx(1, "[FAIL]\tSyscall trampoline returned"); in test_syscall_fallthrough_to()
156 * When the kernel returns from a slow-path syscall, it will in main()
162 for (int i = 47; i < 64; i++) in main()
163 test_sigreturn_to(1UL<<i); in main()
170 test_syscall_fallthrough_to((1UL << 47) - 2*PAGE_SIZE); in main()
173 for (int i = 47; i < 64; i++) { in main()
174 test_syscall_fallthrough_to((1UL<<i) - PAGE_SIZE); in main()
175 test_syscall_fallthrough_to(1UL<<i); in main()