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
30 ".fill 4094,1,0xcc\n\t"
33 ".ifne . - test_page - 4096\n\t"
51 err(1, "sigaction"); in sethandler()
61 err(1, "sigaction"); in clearhandler()
73 if (rip != ctx->uc_mcontext.gregs[REG_RIP]) { in sigsegv_for_sigreturn_test()
75 rip, (unsigned long)ctx->uc_mcontext.gregs[REG_RIP]); in sigsegv_for_sigreturn_test()
77 _exit(1); in sigsegv_for_sigreturn_test()
80 memcpy(&ctx->uc_mcontext.gregs, &initial_regs, sizeof(gregset_t)); in sigsegv_for_sigreturn_test()
89 memcpy(&initial_regs, &ctx->uc_mcontext.gregs, sizeof(gregset_t)); in sigusr1()
92 ctx->uc_mcontext.gregs[REG_RIP] = rip; in sigusr1()
93 ctx->uc_mcontext.gregs[REG_RCX] = rip; in sigusr1()
96 assert(ctx->uc_mcontext.gregs[REG_EFL] == in sigusr1()
97 ctx->uc_mcontext.gregs[REG_R11]); in sigusr1()
117 if (rip != ctx->uc_mcontext.gregs[REG_RIP]) { in sigsegv_for_fallthrough()
119 rip, (unsigned long)ctx->uc_mcontext.gregs[REG_RIP]); in sigsegv_for_fallthrough()
121 _exit(1); in sigsegv_for_fallthrough()
124 siglongjmp(jmpbuf, 1); in sigsegv_for_fallthrough()
129 void *new_address = (void *)(ip - 4096); in test_syscall_fallthrough_to()
137 if (ip <= (1UL << 47) - PAGE_SIZE) { in test_syscall_fallthrough_to()
138 err(1, "mremap to %p", new_address); in test_syscall_fallthrough_to()
146 errx(1, "mremap malfunctioned: asked for %p but got %p\n", in test_syscall_fallthrough_to()
152 if (sigsetjmp(jmpbuf, 1) == 0) { in test_syscall_fallthrough_to()
154 [syscall_insn] "rm" (ip - 2)); in test_syscall_fallthrough_to()
155 errx(1, "[FAIL]\tSyscall trampoline returned"); in test_syscall_fallthrough_to()
164 * When the kernel returns from a slow-path syscall, it will in main()
170 for (int i = 47; i < 64; i++) in main()
171 test_sigreturn_to(1UL<<i); in main()
178 test_syscall_fallthrough_to((1UL << 47) - 2*PAGE_SIZE); in main()
181 for (int i = 47; i < 64; i++) { in main()
182 test_syscall_fallthrough_to((1UL<<i) - PAGE_SIZE); in main()
183 test_syscall_fallthrough_to(1UL<<i); in main()