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
45 if (rip != ctx->uc_mcontext.gregs[REG_RIP]) { in sigsegv_for_sigreturn_test()
47 rip, (unsigned long)ctx->uc_mcontext.gregs[REG_RIP]); in sigsegv_for_sigreturn_test()
49 _exit(1); in sigsegv_for_sigreturn_test()
52 memcpy(&ctx->uc_mcontext.gregs, &initial_regs, sizeof(gregset_t)); in sigsegv_for_sigreturn_test()
61 memcpy(&initial_regs, &ctx->uc_mcontext.gregs, sizeof(gregset_t)); in sigusr1()
64 ctx->uc_mcontext.gregs[REG_RIP] = rip; in sigusr1()
65 ctx->uc_mcontext.gregs[REG_RCX] = rip; in sigusr1()
68 assert(ctx->uc_mcontext.gregs[REG_EFL] == in sigusr1()
69 ctx->uc_mcontext.gregs[REG_R11]); in sigusr1()
89 if (rip != ctx->uc_mcontext.gregs[REG_RIP]) { in sigsegv_for_fallthrough()
91 rip, (unsigned long)ctx->uc_mcontext.gregs[REG_RIP]); in sigsegv_for_fallthrough()
93 _exit(1); in sigsegv_for_fallthrough()
96 siglongjmp(jmpbuf, 1); in sigsegv_for_fallthrough()
101 void *new_address = (void *)(ip - 4096); in test_syscall_fallthrough_to()
109 if (ip <= (1UL << 47) - PAGE_SIZE) { in test_syscall_fallthrough_to()
110 err(1, "mremap to %p", new_address); in test_syscall_fallthrough_to()
118 errx(1, "mremap malfunctioned: asked for %p but got %p\n", in test_syscall_fallthrough_to()
124 if (sigsetjmp(jmpbuf, 1) == 0) { in test_syscall_fallthrough_to()
126 [syscall_insn] "rm" (ip - 2)); in test_syscall_fallthrough_to()
127 errx(1, "[FAIL]\tSyscall trampoline returned"); in test_syscall_fallthrough_to()
136 * When the kernel returns from a slow-path syscall, it will in main()
142 for (int i = 47; i < 64; i++) in main()
143 test_sigreturn_to(1UL<<i); in main()
150 test_syscall_fallthrough_to((1UL << 47) - 2*PAGE_SIZE); in main()
153 for (int i = 47; i < 64; i++) { in main()
154 test_syscall_fallthrough_to((1UL<<i) - PAGE_SIZE); in main()
155 test_syscall_fallthrough_to(1UL<<i); in main()